What does this line means?
#1

Hey,
i got weapon saving system, but it doesn't saves ammo any more..
Here's the line which would save the ammo:

dini_IntSet(path,string,ammo == 65535 ? 0 : ammo);

Is it correct? And what does that stuff with ? and : means?
Reply
#2

I never knew how to do it, but I know what's for, and what it means. ? is Conditional operator it's used in c++ also. The Conditional operator returns the value in any number or bool you would like. It's formated like this:
Код:
YourStatement ? option1 : option2
A example of this is.
Код:
if(2+2==4) ? true : false; // I think that's how you do it
edit: This is what the PAWN manual says, maybe this can help
Quote:
Originally Posted by Manual
In a case statement and in expressions in the conditional operator
(“ ? : ”), any expression that has a tag override should be enclosed
between parentheses, to avoid the colon to be misinterpreted
as a separator of the case statement or as part of the conditional
operator.
Reply
#3

Quote:
Originally Posted by Carlton
I never knew how to do it, but I know what's for, and what it means. ? is Conditional operator it's used in c++ also. The Conditional operator returns the value in any number or bool you would like. It's formated like this:
Код:
YourStatement ? option1 : option2
A example of this is.
Код:
if(2+2==4) ? true : false; // I think that's how you do it
edit: This is what the PAWN manual says, maybe this can help
Quote:
Originally Posted by Manual
In a case statement and in expressions in the conditional operator
(“ ? : ”), any expression that has a tag override should be enclosed
between parentheses, to avoid the colon to be misinterpreted
as a separator of the case statement or as part of the conditional
operator.
Ok thanks..
I wonder what would this mean:
ammo == 65535
If ammo is 65535 that means there is no ammo? :\
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)