SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 09/07/2016, 05:10 PM   #1
majesticz03
Little Clucker
 
Join Date: Jun 2016
Posts: 17
Reputation: 0
Default cmd ban crashing my server

Server is crashing when i use the command can some help me please

Code:
CMD:ban(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 1 || PlayerInfo[playerid][pBanAppealer] >= 1 || PlayerInfo[playerid][pModerator] >= 1 || PlayerInfo[playerid][pSecretAdmin] >= 1)
	{
		new string[128], giveplayerid, reason[64];
		if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ban [playerid/partofname] [reason]");

        //if(AntiAdv(playerid, params)) return 1;
		if(IsPlayerConnected(giveplayerid))
		{
			if(PlayerInfo[giveplayerid][pAdmin])
			{
				if(AdminDuty[playerid] == 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(playerid, "TempNameName", username, sizeof(username));
					SetPVarInt(playerid, "TempName", 0);
					SetPlayerName(playerid, username);
				}
				format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", PlayerInfo[playerid][pAdminName]);
				ABroadCast(COLOR_YELLOW,string,2);
				PlayerInfo[playerid][pBanned] = 1;
				new ip[32];
				GetPlayerIp(playerid,ip,sizeof(ip));
				AddBan(ip);
				Kick(playerid);
				return 1;
				SendClientMessageEx(playerid, COLOR_REALRED, "You are not authorized to ban administrators.");
			}
			else
			{
				new playerip[32];
				GetPlayerIp(giveplayerid, playerip, sizeof(playerip));

				if(AdminDuty[giveplayerid] == 1 || PlayerInfo[playerid][pAdmin] >= 5)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(giveplayerid, "TempNameName", username, sizeof(username));
					SetPVarInt(giveplayerid, "TempName", 0);
					SetPlayerName(giveplayerid, username);

					format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "AdmCmd: %s was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], GetPlayerNameEx(playerid), reason);
					ABroadCast(COLOR_LIGHTRED, string, 1);
				}
				else if(PlayerInfo[playerid][pSecretAdmin] >= 1)
				{
					new username[MAX_PLAYER_NAME];
					GetPVarString(giveplayerid, "TempNameName", username, sizeof(username));
					SetPVarInt(giveplayerid, "TempName", 0);
					SetPlayerName(giveplayerid, username);

					format(string, sizeof(string), "SecretAdmin: %s (IP:%s) was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], playerip, GetPlayerNameEx(playerid), reason);
					Log("logs/ban.log", string);
					format(string, sizeof(string), "SecretAdmin: {FFFF00}%s was banned by %s, reason: %s", PlayerInfo[giveplayerid][pAdminName], GetPlayerNameEx(playerid), reason);
					foreach(Player, i)
					{
					    if(PlayerInfo[i][pSecretAdmin] >= 1)
					    {
					        SendClientMessage(i, COLOR_REALRED, string);
					    }
					}
				}


				ABroadCast(COLOR_LIGHTRED, string, 1);
				new ip[32], hour, minute, second, day, month, year;
				gettime(hour, minute, second);
				getdate(year, month, day);
				GetPlayerIp(giveplayerid,ip,sizeof(ip));
				SendClientMessageEx(giveplayerid, COLOR_REALRED, "You're banned from Revenant Roleplay. You can appeal your ban at revenant < Coming soon");
                SendClientMessageEx(giveplayerid, COLOR_LIGHTRED, "-------------------- BAN REPORT --------------------");
				format(string, sizeof(string), "Reason: %s", reason);
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "Current Warnings: %d (3 for BAN)", PlayerInfo[giveplayerid][pWarns]);
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "Staff: %s", GetPlayerNameEx(playerid));
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "IP Address: %s", ip);
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				format(string, sizeof(string), "Time: %02d:%02d:%02d on %02d/%02d/%d", hour, minute, second, day, month, year);
				SendClientMessageEx(giveplayerid, COLOR_WHITE, string);
				SendClientMessageEx(giveplayerid, COLOR_LIGHTRED, "It is strongly recommended that you keep this report for future reference (Press F8)");
				SendClientMessageEx(giveplayerid, COLOR_LIGHTRED, "You may appeal this ban at "WEBSITE".");
				SetTimerEx("BanTimer", 2000, 0, "ds", giveplayerid, ip);
				format(string, sizeof(string), "(%02d:%02d:%02d on %02d/%02d/%d) BanLogs: %s has banned %s, reason: %s",hour,minute,second, day, month, year, GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), reason);
			 	//UpdateRecentBans(string);
				return 1;
			}

		} else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	return 1;
}
majesticz03 is offline   Reply With Quote
Old 09/07/2016, 07:27 PM   #2
Mencent
High-roller
 
Mencent's Avatar
 
Join Date: Mar 2015
Location: Lower Saxony (Niedersachsen)
Posts: 1,311
Reputation: 92
Default Re: cmd ban crashing my server

Hello!

Take the crashdetect plugin to get more information about the crash.
(http://forum.sa-mp.com/showthread.php?t=262796)
__________________
Best wishes,
Mencent

(Sorry for my bad english, I hope you can understand this!)
Mencent is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP]Server crashing[HELP]!!! Cjgogo Scripting Help 4 23/01/2019 08:31 PM
Server Crashing every hour, please help[Provided Server Log with crashdetect] Guest4390857394857 Server Support 5 09/06/2014 10:46 AM
Server crashing VerticalGaming Scripting Help 16 30/03/2014 09:11 PM
Server's crashing. NathNathii Server Support 8 20/09/2013 10:07 PM
New Server Crashing GamerZPro Server Support 2 28/04/2009 02:30 PM


All times are GMT. The time now is 08:22 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.