SA-MP Forums Archive
switch - 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: switch (/showthread.php?tid=493890)



switch - Don_Cage - 10.02.2014

Is the default in switch the same as else in 'if' ?
Example, are these two the same?
pawn Код:
case 4:
        {
            if(PlayerInfo[playerid][pNote5s] == 1)
            {
                strmid(PlayerInfo[playerid][pNote5], "None", 0, strlen("None"), 255);
                PlayerInfo[playerid][pNote5s] = 0;
                SCM(playerid, COLOR_WHITE, "Note (slot 5) has been deleted successfuly.");
            }
            else return SCM(playerid, COLOR_GREY, "**  You don't have a note at slot 5 ! ");
        }
        default: return SCM(playerid, COLOR_GREY,"You can only choose between note 1-5!");
And
pawn Код:
if(blahblah)
        {
            if(PlayerInfo[playerid][pNote5s] == 1)
            {
                strmid(PlayerInfo[playerid][pNote5], "None", 0, strlen("None"), 255);
                PlayerInfo[playerid][pNote5s] = 0;
                SCM(playerid, COLOR_WHITE, "Note (slot 5) has been deleted successfuly.");
            }
            else return SCM(playerid, COLOR_GREY, "**  You don't have a note at slot 5 ! ");
        }
        else return SCM(playerid, COLOR_GREY,"You can only choose between note 1-5!");



Re: switch - Vince - 10.02.2014

The default: case will be called when none of the above cases match. In a way, they are comparable.


Re: switch - Don_Cage - 10.02.2014

yeah that's what I ment, Thanks