Ternary operator... - 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... (
/showthread.php?tid=414195)
Ternary operator... -
Riddick94 - 08.02.2013
pawn Code:
PlayerData[playerid][E_PLAYER_MONEY] += (money > MAX_PLAYER_MONEY ? MAX_PLAYER_MONEY : money);
Any idea why it's not working? I do not want to exceed some value to the player variable E_PLAYER_MONEY.
Re: Ternary operator... -
Riddick94 - 09.02.2013
Bump.
edit://
Fixed.
Re: Ternary operator... -
Pooh7 - 09.02.2013
pawn Code:
PlayerData[playerid][E_PLAYER_MONEY] += (money > MAX_PLAYER_MONEY) ? MAX_PLAYER_MONEY : money;
Only a condition should be parenthesized.
Re: Ternary operator... -
LarzI - 09.02.2013
pawn Code:
PlayerData[playerid][E_PLAYER_MONEY] += ( (money > MAX_PLAYER_MONEY) ? (MAX_PLAYER_MONEY) : (money) );