SA-MP Forums Archive
ternary operator, increasing vars. - 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: ternary operator, increasing vars. (/showthread.php?tid=383480)



ternary operator, increasing vars. - EV007 - 07.10.2012

pawn Code:
(PlayerI[i][Team] == 1) ? ServerI[PlayersInTeamA]++ : ServerI[PlayersInTeamB]++;
how could I make this without getting an warning: expression has no effect?

I want to increase Players in team A if player team == 1, or if its not, it will increase in team B


Re: ternary operator, increasing vars. - ReneG - 07.10.2012

EDIT: nevermind.


Re: ternary operator, increasing vars. - EV007 - 07.10.2012

What did you change? Everything's the same, except you changed the var from ServerI to server. Gives the warning still.


Re: ternary operator, increasing vars. - ReneG - 07.10.2012

Ternary operators are used to return values, not expressions.

Example
PHP Code:
new var;
printf("Variable is %s", var == ? ("Off") : ("On")); 
will print "Variable is Off"