Originally Posted by BenzoAMG
pawn Код:
CMD:ban(playerid, params[]) { if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command"); new targetid, reason[30]; if(sscanf(params, "us[30]", targetid, reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [id] [reason]"); if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "The player is not connected."); new pName[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], day, month, year, hour, minute, second, string[128]; GetPlayerName(playerid,pName,MAX_PLAYER_NAME); GetPlayerName(playerid,targetname,MAX_PLAYER_NAME); getdate(day, month, year); gettime(hour, minute, second); SendClientMessage(targetid, COLOR_RED, "You have been banned by an Administrator. If you feel that you were wrongly banned, appeal at: sfcnr.smfnew.com"); SendClientMessage(targetid, COLOR_RED, "Ban Information"); format(string, sizeof(string), "Banned by: %s(AdminLevel:%d)", pName, PlayerInfo[playerid][pAdmin]); SendClientMessage(targetid, COLOR_RED, string); format(string, sizeof(string), "Ban reason: %s", reason); SendClientMessage(targetid, COLOR_RED, string); format(string, sizeof(string), "Date & Time of the ban: %d/%d/%d at %d:%d:%d.", day, month, year, hour, minute, second); SendClientMessage(targetid, COLOR_RED, string); SendClientMessage(targetid, COLOR_RED,"Please press the F8 button to take a screenshot to use it on your appeal"); format(string, sizeof(string), "[{FF0000}BAN{EEEEEE}]Administrator %s has banned %s for %s",pName,targetname,reason); SendClientMessageToAll(COLOR_WHITE,string); PlayerInfo[targetid][pBanned] = 1; SetTimerEx("BanPlayer", 200, false, "i", targetid); return 1; }
forward BanPlayer(playerid); public BanPlayer(playerid) return Ban(playerid);
Since 0.3e, when a user is kicked or banned, the server closes the connection from client to server immediately due to security updates. This means that the clients may not receive the messages that you send through SendClientMessage before applying Kick or Ban(playerid). A workaround to this is to use a timer such as 'SetTimerEx("BanPlayer", 200, false, "i", playerid);'.
|