12.04.2012, 00:48
You're not getting any parameters at all, that's why. You simply declared value(default is 0) and there's no parameter for the player's ID or name.
You should do this
The cmd variable would be the one to detect the command used, so
Use this one(ReturnUser) to return the player's ID or name:
http://pastebin.com/A5CZ46C2
I highly recommend using sscanf and ZCMD though, rather than this.
pawn Код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
pawn Код:
new param[64], cmd[64], idx;
cmd = strtok(cmdtext, idx);
pawn Код:
if(!strcmp(cmd, "/setskin", true))
{
if(PlayerInfo[playerid][pAdmin] >= 2)
{
// declare the variables
new targetid, skin, string[128];
// get the first parameter, which is the playerid
param = strtok(cmdtext, idx);
if(!strlen(param)) return SendClientMessage(playerid, -1, "Usage: /setskin [PlayerID] [SkinID]");
targetid = param;
// second parameter, which is the skin id
param = strtok(cmdtext, idx);
if(!strlen(param)) return SendClientMessage(playerid, -1, "Usage: /setskin [PlayerID] [SkinID]");
skin = strval(param);
// check if the input is a valid skin id
if(IsInvalidSkin(skin)) return SendClientMessage(playerid, -1, "Invalid skin ID!");
// set the player's skin and send the message
format(string, sizeof(string), "You have set %s's skin to %d", GetName(targetid), skin);
SendClientMessage(playerid, -1, string);
SetPlayerSkin(targetid, skin);
}
else SendClientMessage(playerid, -1, "ERROR: You are unauthorized to use this command.");
return 1;
}
http://pastebin.com/A5CZ46C2
I highly recommend using sscanf and ZCMD though, rather than this.

