29.11.2016, 15:14
Hello, I've added shell system to my gamemode which drops a "shell" when you fire a weapon. Everything works well except a ternany operator.
Here's the code:
I want to tell the player to wait "%d more seconds" if the seconds (variable "time") are above 1 and "%d more second" if the amount of seconds is 1. It tells me "seconds" every time I need to wait 5, 3, 2 or 1 seconds and "second" when I need to wait 4 seconds . As you can see I'm doing 5 - time, which equals to 4, but if I won't do that then the time is 1. Maybe that's why it says "second" for 4 (because if it's 4 then the "time" variable equals to 1)? Because nothing seems to be wrong there.
Here's the code:
Code:
new time = (tickcount() - ShellInfo[id][ShellTick]) / 1000; if (time < 5) return SendClientMessageEx(playerid, COLOR_LIGHTRED, "The shell is too hot, you must wait %d more %s before picking it up.", 5 - time, (time == 1) ? ("second") : ("seconds"));