Setting skins
#10

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.
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;
}
You should do this
pawn Код:
new param[64], cmd[64], idx;
cmd = strtok(cmdtext, idx);
The cmd variable would be the one to detect the command used, so
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;
    }
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.
Reply


Messages In This Thread
Setting skins - by nmader - 12.04.2012, 00:14
Re: Setting skins - by The__ - 12.04.2012, 00:18
Re: Setting skins - by nmader - 12.04.2012, 00:23
Re: Setting skins - by The__ - 12.04.2012, 00:25
Re: Setting skins - by The__ - 12.04.2012, 00:31
Re: Setting skins - by nmader - 12.04.2012, 00:35
Re: Setting skins - by The__ - 12.04.2012, 00:36
Re: Setting skins - by nmader - 12.04.2012, 00:37
Re: Setting skins - by The__ - 12.04.2012, 00:40
Re: Setting skins - by Skribblez - 12.04.2012, 00:48

Forum Jump:


Users browsing this thread: 1 Guest(s)