[Help] Switch statement question - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help] Switch statement question (
/showthread.php?tid=469541)
[Help] Switch statement question -
basse - 13.10.2013
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!
Re: [Help] Switch statement question - Emmet_ - 13.10.2013
You don't need a switch statement.
pawn Код:
new skin = GetPlayerSkin(playerid);
if (skin >= 280 && skin <= 286) {
skin++;
}
SetPlayerSkin(playerid, skin);
Re: [Help] Switch statement question -
xVIP3Rx - 13.10.2013
You're using it wrong, Here're the right way
pawn Код:
switch(GetPlayerSkin(playerid))
{
case case 281 .. 286: SetPlayerSkin(playerid, 281);
}
Re: [Help] Switch statement question -
basse - 13.10.2013
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!
Re: [Help] Switch statement question -
Konstantinos - 13.10.2013
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.