01.08.2015, 15:17
You should add a line to check if you're trying to ban/kick yourself on the kick command too.
pawn Код:
CMD:ban(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You need to be admin for use this command.");
new PID, reason[64];
if(sscanf(params, "us[64]", PID,reason)) return SendClientMessage(playerid, 0xFF0000FF, "/ban [playerid] [reason]"); //tell sscanf if the parameters/the syntax is written wrong to return a message (PID and the reason used here)
if(!IsPlayerConnected(PID) return SendClientMessage(playerid, 0xFF0000FF, "Player is not connected!");
if(PID = playerid) return SendClientMessage(playerid, 0xFF0000FF, "You're trying to ban yourself.");
new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME]; //defines the function with the playername we wanna get
GetPlayerName(playerid, Adminname, sizeof(Adminname)); //defines the function with the adminname we wanna get
GetPlayerName(PID, Playername, sizeof(Playername));
new str[128];
format(str, sizeof(str), "'%s' has been banned by administrator '%s'. Reason: %s.", Playername, Adminname, reason); //format the string we've defined to send the message, playername and adminname are used to receive the information about the names
SendClientMessageToAll(0xFF6C00FF, str); //send that message to all
Ban(PID);
return 1;
}