Ternary operator - Variable not used? - 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 - Variable not used? (
/showthread.php?tid=484145)
Ternary operator - Variable not used? -
kristo - 29.12.2013
pawn Код:
new bool:autos = (IsPlayerInAnyVehicle(playerid) && !IsABike(vid) && !AutoInfo[vid][vAken]);
LimiteeritudKaugus((autos ? 5 : 20), playerid, COLOR_WHITE, string)
SetPlayerChatBubble(playerid, text, COLOR_WHITE, (autos ? 5 : 20), aeg);
As you can see, I have used the variable "autos" twice but I still get this warning:
C:\Users\Kristo\Dropbox\Server (2)\IMPO\Server\gamemodes\imperial.pwn(3389) : warning 204: symbol is assigned a value that is never used: "autos"
What should I do?
Re: Ternary operator - Variable not used? -
MatriXgaMer - 29.12.2013
Try putting on the top of your script
Re: Ternary operator - Variable not used? -
Stereotype - 29.12.2013
Booleans are automaticly false .. should use
pawn Код:
if(autos == true) { /* do whatever you want */ }
Re: Ternary operator - Variable not used? -
kristo - 29.12.2013
Please... Just don't... Those answers were terrible.
There actually was another variable called "autos" and that one wasn't used.