[Help] Switch statement question
#1

Hello guys i have always used if-else but i want to try switch and now i am thinking if this is possible or how to do it similiarly.

switch(GetPlayerSkin() == 280)
case: skin id 281
SetPlayersKin 281;


like if the skin id is 280 it will turn into 281
and so on, from skin id 280 to 286, Thanks in advance,
I am sorry if you can't understand but ask and i will Try to give a better explanation!


*** Edit ***

Thanks everyone, my problem got solved quick!
Reply
#2

You don't need a switch statement.

pawn Код:
new skin = GetPlayerSkin(playerid);
if (skin >= 280 && skin <= 286) {
    skin++;
}
SetPlayerSkin(playerid, skin);
Reply
#3

You're using it wrong, Here're the right way
pawn Код:
switch(GetPlayerSkin(playerid))
{
    case case 281 .. 286: SetPlayerSkin(playerid, 281);
}
Reply
#4

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
You don't need a switch statement.

pawn Код:
new skin = GetPlayerSkin(playerid);
if (skin >= 280 && skin <= 286) {
    skin++;
}
SetPlayerSkin(playerid, skin);
Thanks alot mate!
Reply
#5

I didn't really understand what you want.
pawn Код:
switch( GetPlayerSkin( playerid ) )
{
    case 280: SetPlayerSkin( playerid, 281 );
    case 281: SetPlayerSkin( playerid, 282 );
}
If the skin is 280, it sets it to 281.
If the skin is 281, it sets it to 282.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)