Since apparently everyone simply assumes that everybody here uses the third party library sscanf, here is a version that would run even without sscanf, although I'd not recommend it.
pawn Код:
if (!strcmp("/killp", cmdtext, true, 5))
{
new tmp[10], idx;
strtok(cmdtext, idx); tmp=strtok(cmdtext, idx);
if(!strlen(tmp)) { return SendClientMessage(playerid, 0xFFFFFF, "USAGE: \"/killp [PlayerID\""); }
new userid = strval(tmp);
if(userid < 0 || userid > MAX_PLAYERS) { return SendClientMessage(playerid, 0xFFFFFF, "USAGE: \"/killp [PlayerId]\""); }
SetPlayerHealth(userid, 0);
}
Now I admit I didnt test this code and it relies on the fact that you do NOT have the following line somewhere on the top of OnPlayerCommandText:
pawn Код:
cmd = strtok(cmdtext, idx); // where as cmd could be any string name really and so could be idx!
If you do, simply remove the first strtok. I am also unaware wether simply executing an strtok without fetching the result is possible. Anyway, I hope it helps and I am sure it gives you a general idea. If you have any further questions feel free to ask, I'll gladly explain the code.