21.01.2011, 08:58
pawn Код:
dcmd_ban(playerid,params[])
{
new id, name[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
new tmp[256], Index, str[49];
tmp = strtok(params,Index), id = strval(tmp);
GetPlayerName(id,on,sizeof(on));
GetPlayerName(playerid,name,sizeof(name));
if(pInfo[playerid][Level] < 3) return SendClientMessage(playerid,RED,">> You Need To Be Level 3+ To Use This Command!");
if(!strlen(params)) return SendClientMessage(playerid,RED,"USAGE: /ban [id] ");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,RED,">> Invalid [id]!");
tmp = strrest(params, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, RED, "/USEAGE: /ban [id] [reason]");
format(str,sizeof(str),">> Administrator %s Has Banned %s From The Server! (%s)",name,on, tmp);
SendClientMessageToAll(RED,str);
Ban(id);
return 1;
}
stock strrest(const string[], index)
{
new length = strlen(string),offset = index,result[256];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
id will be 0.... if you now enter: "1 you are noob"... it will still be 0 as "you are noob" is still within the string but no number and strval creates an integer of the whole string, so if it isn't a number it always returns 0