08.04.2012, 21:40
Using strtok to check parameters is an impractical way of making commands.
Here you can see a ban command be made in 20 lines.
Here you can see a ban command be made in 20 lines.
pawn Код:
CMD:ban(playerid,params[])
{
new string[128],
reason[50],
target;
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not allowed to use this command.");
if(sscanf(params,"us[50]",target,reason)) return SendClientMessage(playerid, -1, "USAGE: /ban [playerid] [reason]");
else
{
new
name[24],
targetname[24];
GetPlayerName(playerid,name,sizeof(name));
GetPlayerName(target,targetname,sizeof(targetname));
format(string,sizeof(string),"Administrator %s has banned %s. Reason: %s",name,targetname,reason);
SendClientMessageToAll(-1, string);
Ban(target);
}
return 1;
}