Sleep not working
If you can't get sleep to work (like I couldn't for ages, tearing my hair out in the process!), check for the following:
- If you are using an SQF script, but have comments marked with ";" instead of "//", Arma will not give you an error message, but sleep statements will provide no delay - the engine seems to simply ignore them.
- ; are no comment identifiers in SQF. Most likely you use sleep in a context where it is not permitted.
- Post your example code in http://pastebin.jonasscholz.de. Without your post is of no use.
- Overall you are better of posting in BIF or OFPEC about your problem. --Kju 13:12, 10 May 2010 (CEST)
Does this command also work in functions? --T_D 20:15, 21 July 2006 (CEST)
I don't think functions ever sleep. They must start and finish, returning the result somewhere, even if it is to null.
They don't pause,,,,thats my understanding anyway.
Planck 20:25, 21 July 2006 (CEST)
I think yes...
I think yes, functions are as piece of code as other piece of code.
Djura 20:30, 21 July 2006 (CEST)
Djura, as the new Armed Assault script commands are still WIP, I don't think it is wise to add information to them other than that which we were supplied with by BI.
The description for sleep supplied was 'Suspend execution of script for given time.'
I won't remove what you added but it would be wiser to wait till BI finalise the command set and its operators.
Planck 13:10, 24 July 2006 (CEST)
- I'll respect it. (For future: Write this kind of messages to my talk page please.) --Djura 19:45, 24 July 2006 (CEST)
For some insight, check my post here: http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=10a67f0f44abe94275f48130af94f253;act=ST;f=71;t=55788;st=30
Igor Drukov 23:30, 16 December 2006 (GMT+1)
Generic error in expression
When I use the sleep command in a script, the game says : |#|sleep 1; ... Generic error in expression. Note that the |#| isn't in my code, it's just in the error message. It says this however I use the command... I tried a workaround using waitUntil, but it throws the same error message. I can't suspend scripts in Armed Assault...?
- You have to execute the script with execVM or spawn. --raedor 15:19, 12 February 2007 (CET)
Kronzky : Sleep durations between .0005 and .02 will cause the same delay (roughly .02 seconds). Delays of .0005 and less have no effect.
- Isn't it directly related to FPS and therefore system dependant? 0.02 seconds = ~50fps. --Ceeeb
- Yes, the absolute delay varies (that's why I put in "roughly"), but the main point is that it doesn't matter whether you use a delay of .01 or .001, as they end up being the same. --Kronzky 03:41, 13 February 2007 (CET)
- Experimation shows that sleep granularity is measured in frames. Sleep 0.001 is equivalent to 'wait for next frame' no matter how fast your PC. Sleep 0.02 = 0.02 seconds at 50fps or (not so obviously) 0.032 seconds at 60fps. Basically, you shouldn't try to use sleep for fine-grained timing.
I have noticed that if I attempt to execute the following;
Then a bug in the parser causes the machine to sleep for _timeToWaitUntil seconds.
Adding brackets solves the problem and it behaves as expected:
- That's how the scripting language was designed and not a bug. --T_D 13:31, 10 May 2010 (CEST)
sleep anomaly on jip
- Posted on May 29, 2015 - 02:59 (UTC)
- Waffle SS.
- The sleep command will be ignored on JIP. This affects code/functions called from init.sqf or object initialization. It will simply ignore the command and continue through the code. Even if spawn is used to create a new process.
- Seems to be connected to time == 0 at the start of init.sqf.