Jump to content
Sign in to follow this  
snkman

_time command in .sqf

Recommended Posts

Hey guy's,

well i just wanna to know, how to get the _time command to work in an .sqf script?

At the Biki someone told, that _time and .sqf may work and may not...? crazy_o.gif

So now whats fact? Does it work or not? In all my tests it didn't work, but well may i did something wrong, but with:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_f = 10;

_time = 0;

while {_time < _f} do {

_time = _time + 1;

hint "Working";

sleep 1;

hint "";

}

It works like a dream, so i think it just do not work in .sqf

But i just wanna to hear it from some other guy's too, to be sure. wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]well i just wanna to know, how to get the _time command to work in an .sqf script?

You could write the same code like this, if you prefer to stick with the game time. I kept the sleep in, as it's not a good idea to run a while loop without some kind of pause:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_time = Time+10;

while {Time < _time} do

       {

       hint "Working";

       sleep 1;

       hint "";

       }

Share this post


Link to post
Share on other sites

afaik is/was _time a reserved variable which contained the time a script was runnin. So a

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

hint format ["%1", _time];

would return how long the script is runnin. As the global variable "time" contains the value how long the mission is runnin.

In your test script you do re-assign _time to an own value, therefor it returns this value and NOT the time the script is runnin.

As the Biki says, "time" (the global variable) will work in sqf called by execVM but "_time" (the local variable) will NOT work in a sqf called by execVM.

If you want to use _time by it's meaning, you have to fall back to sqs as there it still will work.

Or you store the actual "time" value once to compare it later on, some sort of "mark start point on timeline. But there might be issues as time is reseted after save/load a mission.

Hope this helps

Myke out

Share this post


Link to post
Share on other sites

Okay smile_o.gif

Thank you guy's for the helping replay.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×