What does this line means? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What does this line means? (
/showthread.php?tid=139344)
What does this line means? -
SiJ - 04.04.2010
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?
Re: What does this line means? -
Carlton - 04.04.2010
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.
|
Re: What does this line means? -
SiJ - 04.04.2010
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? :\