12.04.2011, 11:14
pawn Код:
COMMAND:ban(playerid,params[])
{
new id,reason[101],me[MAX_PLAYER_NAME],target[MAX_PLAYER_NAME];
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,red,"You are not an admin!");
if (sscanf(params,"is",id,reason)) return SendClientMessage(playerid, red, "USAGE: /ban [ID]");
if (id == playerid) return SendClientMessage(playerid,red,"You can't ban yourself!");
if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, red, "Player not found");
if (strlen(reason) < 101) return SendClientMessage(playerid,red,"Your reason must be less than 101 characters!");
if (IsPlayerAdmin(id))
{
SendClientMessage(playerid,red,"You can't ban an admin!");
new errstring[128], me;
GetPlayerName(playerid,me,sizeof(me));
format(errstring,sizeof(errstring),"%s has tried to ban you, but failed", me);
SendClientMessage(id,red,errstring)
return 1;
}
else
{
new mess[128], me, target;
GetPlayerName(playerid,me,sizeof(me));
GetPlayerName(id,target,sizeof(target));
format(mess,sizeof(mess),"Administrator \"%s\" has banned \"%s\". (Reason: %s)",me,target,reason);
SendClientMessageToAll(red,mess);
Ban(id);
return 1;
}
return 1;
}
It should be optimized creating an stock with GetPlayerName, as we use it lot of times, test it now as i cant, as soon as im outta college i will test it myself and optimizate it if you still need some help, i guess this one should work fine if not reply here, and fix the identation or it will give you those warnings.