SA-MP Forums Archive
what does this mean? - 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: what does this mean? (/showthread.php?tid=335321)



what does this mean? - TheMightyEddy - 17.04.2012

So i found this in another script and what does this mean?:

pawn Код:
switch(classid)
    {
        case 0, 1, 2, 3, 4, 5:
        {
            GameTextForPlayer(playerid, "~b~Law Enforcement", 3000, 5);
        }
        case 6:
        {
            GameTextForPlayer(playerid, "~p~Los Santos Army", 3000, 5);
        }
        case 7:
        {
            GameTextForPlayer(playerid, "~b~FBI official", 3000, 5);
        }
        case 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29:
        {
            GameTextForPlayer(playerid, "~w~Civilian", 3000, 5);
        }
    }
I know when I switch class, it will say what skill I am. But I added much more classes and it doesnt switch. PLease help?


Re: what does this mean? - Luis- - 17.04.2012

Show the ones you added.


Re: what does this mean? - TheMightyEddy - 17.04.2012

I just added all 299 classes. It's just when I click on the arrow the switch skins, it will only saw "Law Enforcement" on some skins and "Civilian" on other skins.


Re: what does this mean? - TheMightyEddy - 18.04.2012

Please help?


Re: what does this mean? - Slice - 18.04.2012

https://sampwiki.blast.hk/wiki/Control_Structures#switch_2

There is so much information you could learn, simply by searching the SA-MP Wiki or ******. If you want to learn programming and you can't look for things yourself, you won't get very far.


Re: what does this mean? - TheMightyEddy - 18.04.2012

Okay thanks. But what does this mean? The so many numbers after case:

Код:
case 0, 1, 2, 3, 4, 5:



Re: what does this mean? - Vince - 18.04.2012

Is the same as doing:
pawn Код:
if(classid == 0 || classid == 1 || classid == 2 || classid == 3 || classid == 4 || classid == 5)
As you see, a switch is much easier to maintain.


Re: what does this mean? - Slice - 18.04.2012

pawn Код:
// Alright, say we have some variable
new some_variable = 14;

// Now we need to do different things, depending on what it is.
// A neat way to do this is by using "switch".

// Now we say "alright, I want to compare some_variable to a bunch of things"
switch (some_variable) {
    // Is it 1, 2, or 3?
    case 1, 2, 3: {
        printf("It's 1, 2, or 3!");
    }
   
    // Is it between 5 and 10?
    case 5 .. 10: {
        printf("It's between 5 and 10!");
    }
   
    // Is it 14?
    case 14: {
        printf("It's 14!");
    }
   
    // If it's none of the above "cases"
    default: {
        printf("I'm not sure what it is!");
    }
}



Re: what does this mean? - kikito - 18.04.2012

Your case have many numbers, because the number "x" is for the classid "x".


Re: what does this mean? - Mark™ - 18.04.2012

Quote:
Originally Posted by TheMightyEddy
Посмотреть сообщение
Okay thanks. But what does this mean? The so many numbers after case:

Код:
case 0, 1, 2, 3, 4, 5:
That's for case 0 to case 5, it does the same thing.