Hey,
what does Citizen.Wait(X) ? Saw it in multiple script but I don’t understand the meaning. And what are the X values ? I saw 1 and 0
Hey,
what does Citizen.Wait(X) ? Saw it in multiple script but I don’t understand the meaning. And what are the X values ? I saw 1 and 0
Citizen.Wait(X) make the thread sleep during X milliseconds
So why sometime is there Citizen.Wait(0) ?
idk, sometimes it’s require because client side is very weird ^^
For some reason when you use a loop (while true do…), the game will freeze without the ‘wait’ in place.
I’m not technical enough to tell you why its needed, but I just know thats how it works and why the Wait(0) is used.
Wait(0) will yield until the next game frame.
How often do game frames ‘happen’?
You can’t predict that - it could be in a second, it could also be in 6 milliseconds.
Okay.
So is there a good way to create a reliable timer in a client side file other than using unpredictable game frames?
I know of SetTimeout for the server, but what about a client file?
EDIT: actually, so I guess we should just use Citizen.Wait(X) where X = the amount of time in milliseconds… lol right?
The same function exists on the client.
Yes.
Since no one answered it very clearly, in my testing it’s a ms timer with the minimum being 1 frame. So if a frame is 16 ms, citizen.wait(0-15) all behave the same. It’s always there because it stops the loop from executing more then once per frame.