what does this mean?
#1

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?
Reply
#2

Show the ones you added.
Reply
#3

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.
Reply
#4

Please help?
Reply
#5

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.
Reply
#6

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

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

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.
Reply
#8

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!");
    }
}
Reply
#9

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)