Setskin is going mental at me!
#1

Please, Do not tell me that strtok and strcmp are old. I know.

The Errors.
pawn Код:
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(77) : error 017: undefined symbol "strtok"
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(77) : error 033: array must be indexed (variable "cmd")
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(78) : error 035: argument type mismatch (argument 1)
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(78) : error 001: expected token: ")", but found ";"
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(78) : error 036: empty statement
C:\Users\Jeremy_2\Desktop\Samp Server\gamemodes\DriftLegion.pwn(78) : fatal error 107: too many error messages on one line


The lines.
pawn Код:
cmd = strtok(cmdtext, idx);
        if(!strlen(3, cmd);

The whole command

pawn Код:
if (strcmp("/setskin", cmdtext, true, 10) == 0)
    {
        new cmd[3], tmp[3], idx;
        cmd = strtok(cmdtext, idx);
        if(!strlen(3, cmd);
        {
            SendClientMessage(playerid, COLOUR_RED, "USAGE: /setskin [Skin ID]");
            return 1;
        }
        else
        if(cmd < 299);
        {
            SendClientMessage(playerid, COLOUR_RED, "There are no skins over ID 299!");
            return 1;
        }
        else
        SetPlayerSkin(playerid, cmd);
        return 1;
    }

Please help me.
Reply
#2

Try this
pawn Код:
if (strcmp("/setskin", cmdtext, true, 10) == 0)
{
    new cmd, idx;
    new tmp[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
        SendClientMessage(playerid, -1, "USAGE: /setskin [Skin ID]");
        return 1;
    }
    else
    if(cmd < 299)
    {
        SendClientMessage(playerid, -1, "There are no skins over ID 299!");
        return 1;
    }
    else
    {
        SetPlayerSkin(playerid, cmd);
    }
    return 1;
}
Reply
#3

pawn Код:
if (strcmp("/setskin", cmdtext, true) == 0)
{
    new idx;
    new tmp[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /setskin [Skin ID]");
    if(tmp < 0 || tmp > 299) return SendClientMessage(playerid, -1, "There are no skins over ID 299!");
    SetPlayerSkin(playerid, tmp);
    return 1;
}
You are not setting the skin to 'cmd', you are setting it to 'tmp'. The line: if(tmp < 299) would just ruin the whole command, as every skin available is below 299. There is no need for the variable 'cmd'.

EDIT: ALso the line: if (strcmp("/setskin", cmdtext, true, 10) == 0)
is also incorrect. The command '/setskin' does not have 10 characters, so therefore you can either remove it, or change it to 8.

pawn Код:
if (strcmp("/setskin", cmdtext, true) == 0)
Reply
#4

Thanks for the help both of you, but Benzo, Yours has more errors. So Ironboy. It still says strtok is undefined and that tmp must be indexed?
Reply
#5

You need to have the strtok function in your script, it isn't a default function inside of SA-MP. See Strtok on the Wiki.

Although, I suggest trying to use Sscanf, as it works much easier and you don't have to use all those resource wasting variables called "cmd" and "tmp" and "idx".
Reply
#6

Well try to define strtok then...
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/setskin", cmdtext, true) == 0)
    {
        new idx;
        new tmp[256];
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /setskin [Skin ID]");
        if(tmp < 0 || tmp > 299) return SendClientMessage(playerid, -1, "There are no skins over ID 299!");
        SetPlayerSkin(playerid, tmp);
        return 1;
    }
    return 0;
}

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)