Little help.
#1

Alright, the problem is this: I have a /skin command with the ID's of 1-6. So it would be like this:

/skin 4

But when I do that, it does nothing. But when I do /skin with nothing after it it sets a skin to a Cadet (As I set up in the command). Here is the command, if anyone can help me please.


pawn Код:
command(skin, playerid, params[])
{
    new text;
    if(sscanf(params,"d",text))
    if(Player[playerid][Group] == 4)
    {
        switch(text)
        {
            case 0:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 71);
                }
            }
            case 1:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 141);
                }
            }
            case 2:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 187);
                }
            }
            case 3:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 70);
                }
            }
            case 4:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 165);
                }
            }
            case 5:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 166);
                }
            }
        }
    }
    return 1;
}
Reply
#2

Corrected code, hope it will works.
pawn Код:
command(skin, playerid, params[])
{
new text;
if(sscanf(params,"d",text))
{
    SendClientMessage(playerid,COLOR,"Error msg.");
    return 1;
}
    if(Player[playerid][Group] == 4)
    {
        switch(text)
        {
            case 0:
            {
                    SetPlayerSkin(playerid, 71);

            }
            case 1:
            {

                    SetPlayerSkin(playerid, 141);

            }
            case 2:
            {

                    SetPlayerSkin(playerid, 187);

            }
            case 3:
            {

                 SetPlayerSkin(playerid, 70);
           
            }
            case 4:
            {

                 SetPlayerSkin(playerid, 165);

            }
            case 5:
            {
                 SetPlayerSkin(playerid, 166);
            }
        }
    }
    return 1;
}
}
Reply
#3

Could you please explain what you actually fixed, so then I know for next time? Appreciated.
Reply
#4

pawn Код:
command(skin, playerid, params[])
{
    new text;
    if(!sscanf(params,"d",text))
    {
        if(Player[playerid][Group] == 4)
        {
            switch(text)
            {
                case 0:
                {
                    if(Player[playerid][Group] == 4)
                    {
                        SetPlayerSkin(playerid, 71);
                    }
                }
                case 1:
                {
                    if(Player[playerid][Group] == 4)
                    {
                        SetPlayerSkin(playerid, 141);
                    }
                }
                case 2:
                {
                    if(Player[playerid][Group] == 4)
                    {
                        SetPlayerSkin(playerid, 187);
                    }
                }
                case 3:
                {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 70);
                }
            }
            case 4:
            {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 165);
                }
            }
            case 5:
                    {
                if(Player[playerid][Group] == 4)
                {
                    SetPlayerSkin(playerid, 166);
                }
            }
        }
    }
    return 1;
}
Reply
#5

No problem.

First:
pawn Код:
if(sscanf(params,"d",text))
{
    SendClientMessage(playerid,COLOR,"Error msg.");
    return 1;
}
I really think, that while you are using if(sscanf(..)) condition, you've to make action below it, to be sure, that it WILL work.
Instead of "Error msg." you can write either "Learn to use command, foul" or "Error. Try again. USAGE: /skin [0-5]
Why 0-5? Look at the switch function.

Oh, forget about command header (damn).
Instead
pawn Код:
command(skin, playerid, params[])
give
pawn Код:
command:skin(playerid, params[])
if command(skin, playerid, params[]) works for you, don't edit it.

Second modification: I do not see sense, of using "if(Player[playerid][Group] == 4" in each 'case' in 'switch' function, if 'switch' function will only continue, if this condition is done
pawn Код:
if(Player[playerid][Group] == 4)
    {
        switch(text)
...
Reply
#6

Thank you!
Reply
#7

Your welcome,
if I've helped: please rep me by pressing "star" button

Greetings,
LetsOWN.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)