PDA

View Full Version : Little help.


iGetty
11/10/2011, 03:45 PM
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.


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

LetsOWN[PL]
11/10/2011, 03:50 PM
Corrected code, hope it will works.

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

iGetty
11/10/2011, 03:52 PM
Could you please explain what you actually fixed, so then I know for next time? Appreciated.

aRoach
11/10/2011, 03:56 PM
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;
}

LetsOWN[PL]
11/10/2011, 03:59 PM
No problem.

First:
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 command(skin, playerid, params[])
give
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
if(Player[playerid][Group] == 4)
{
switch(text)
...

iGetty
11/10/2011, 04:01 PM
Thank you!

LetsOWN[PL]
11/10/2011, 04:02 PM
Your welcome,
if I've helped: please rep me by pressing "star" button :)

Greetings,
LetsOWN.