#1

Is that possible to check is variable value is 20, 40, 60, 80, 100, 120 and so on without checking it with || (I mean if(something == 20 || something == 40) and so on.
Reply
#2

Could use switch case
pawn Код:
switch(var)
{
case 20:
case 40:
etc
}

pawn Код:
switch(var)
{
case 20..120: //I think thats how it works, or might be 3 dots
}
^ but that'd be 20, 21, 22 etc.
Reply
#3

Switch.
pawn Код:
switch( varname ) {
    case 20, 40, 60, 80, 100, 120: {
        //Your code goes here.
    }
    default: {
        //If it is non of these values.
    }
}
EDIT: I was late.
Reply
#4

Your first example will work same as if(something == 20 || something == 40)

And second - this will include values like 21, 35, 47 and so on. I need to check is it only 20, 40, 60, 80, 100, 120, 140, 160, 180 and so on.

Mean: same as first post.. I will need to add values, there's other way I think?
Reply
#5

Then no there isn't.

you're saying you want a different of checkign if something equals something, other than using '==' or switches? I don't see how that'd be done.
Reply
#6

Why don't you want to use switches/if? I see no reason not to.
Reply
#7

Mind If I ask, but can you please tell us why do you need to check too much?
We might find you an easier way instead of chicking them all.
Reply
#8

for example: if speed camera detected player 20 times, then he will lost car license, I mean if 20, 40, 60, 80, 100 times and so on.
Reply
#9

Just use the switch then, can't think about a way.
Reply
#10

damn, that would be fuckin long?

case 20, 40, 60, 80, 120, 140, 160, 180, 200.. D.A.M.N :O
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)