Hey i want to do a timer and it triggers an event once the timer fellt to 0. I did this but it doesn’t work
while temps>0 do
Wait(1)
temps=temps-1
TriggerEvent('chatMessage', "test", {255, 0, 0}, " Temps restant : "..temps.." secondes")
end
TriggerEvent("unjail")
Have you put this in it’s own thread? As for the chat message not showing it should, assuming this code is being ran on the client side (or it could be failing because you’re calling it too much too fast). You could always try something like
Citizen.CreateThread(function()
local time = 10 -- 10 seconds
while (time ~= 0) do -- Whist we have time to wait
Wait( 1000 ) -- Wait a second
time = time - 1
-- 1 Second should have past by now
end
-- When the above loop has finished, 10 seconds should have passed. We can now do something
TriggerEvent("unjail") -- Call the client event "unjail"
end)