26.11.2014, 03:27
pawn Код:
forward KickTimer(playerid);
ACMD:ban(playerid, params[])
{
if (pInfo[playerid][Adminlevel] < 2)return 0;
new reason[128], string[250];
if(sscanf(params, "us[128]",ID, reason))
return SCM(playerid, orange, "--- /ban <ID> <Reason> ---");
if(ID == IPI)return SCM(playerid, red, "Player is not connected!");
pInfo[ID][Banned]=1;
GetPlayerName(ID,pname,MAX_PLAYER_NAME);
GetPlayerName(playerid,Nam, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s %s has banned %s for %s", AdminLevelName(playerid),Nam, pname, reason);
SCMToAll(red, string);
//Kick(ID); Remove This, this is causing the timer to fail as it is closing the connection immediately
SetTimerEx("KickTimer", 1000, false, "i", playerid); 10ms isn't long enough to show the message, so i changed this to 100
return 1;
}
public OnPlayerConnect(playerid)
{
if(pInfo[playerid][Banned]==1)
{
SCM(playerid, red, "You are banned from the server");
SetTimerEx("KickTimer", 1000, false, "i", playerid);//You can use the same timer for this.
}
return 1;
}
public KickTimer(playerid)
{
Kick(playerid);
return 1;
}