[Problem] /Skin cmd help please
#1

Код:
	if(strcmp("/skin", cmdtext, true, 10) == 0)
	{
	if(IsPlayerInRangeOfPoint(playerid,10,198.9780,-127.8640,1003.5152))
	{
        new tmp[256];
        tmp = strtok (cmdtext, idx);

        if(!strlen(tmp)) SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
        else SetPlayerSkin(playerid, strval(tmp));
    }
    else SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
    return 1;
    }
I have that and it works fine but when I go to the point and do /skin [id] it automatically sets it to the CJ Skin id 0 and I cant change to any other skin anyone know what is the problem ?
Reply
#2

Change it to this.
pawn Код:
if(strcmp(cmd, "/skin", true)==0)
{
    if(IsPlayerInRangeOfPoint(playerid, 10, 198.9780, -127.8640, 1003.5152))
    {
        new tmp[128];
        tmp = strtok (cmdtext, idx);

        if(strlen(tmp)==0) SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
       
        SetPlayerSkin(playerid, strval(tmp));
    }
    else SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
    return 1;
}
Reply
#3

I get this error:
Код:
(184) : error 017: undefined symbol "cmd"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Like 184 is:
Код:
if(strcmp(cmd, "/skin", true)==0)
Reply
#4

removed.
Reply
#5

pawn Код:
new cmd[256];
cmd = strtok(cmdtext, idx);

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
#6

I am really not sure where to put that sorry. Should I put it above the OnPlayerCommandText or in the command somewhere? Please just show me thanks so much !
Reply
#7

Use this:

Add this at the top of OnPlayerCommandText:
pawn Код:
new cmd[128];
cmd = strtok(cmdtext, idx);
then:
pawn Код:
if (strcmp(cmd, "/skin", true) == 0)
        {
        new tmp[256];
        tmp = strtok (cmdtext, idx);
        skinid = strval(tmp);
    if(IsPlayerInRangeOfPoint(playerid,10,198.9780,-127.8640,1003.5152))
    {      
            if(!strlen(tmp)) // Removed ! at TMP. ! means NOT. so !strlen = NOT strlen.
            SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
            return 1; // If you won't return, it will continue the script.
             }
             SetPlayerSkin(playerid, skin);
             SendClientMessage(playerid, COLOR_GREEN, "Your skin has been successfully changed!");
             return 1;
             }
            else
             }
            SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
            return 1;
       }
    }
Getting 26 errors? Add an extra brace '}' at the end of this script.

@Anthony
Stop posting crap.

@The post below me
That's also crap mate, that script 100% fails.
Reply
#8

You put this under OnPlayerCommandText:
pawn Код:
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
So it gets like this (idk):
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[128], idx;
    cmd = strtok(cmdtext, idx);

    if(strcmp(cmd, "/skin", true)==0)
    {
        if(IsPlayerInRangeOfPoint(playerid, 10, 198.9780, -127.8640, 1003.5152))
        {
            new tmp[128];
            tmp = strtok (cmdtext, idx);

            if(strlen(tmp)==0) SendClientMessage(playerid, COLOR_RED, "USAGE: /skin [ID]");
       
            SetPlayerSkin(playerid, strval(tmp));
        }
        else SendClientMessage(playerid, COLOR_RED, "You must be in the clothing store.");
        return 1;
    }

    //Other commands here. Dont forget to use cmd instead of cmdtext ;)

    return 0;
}
Put this at bottom of script:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)