Jump to content
loopdk

Stop watch script by triggers

Recommended Posts

Hallo guys.

 

 

I am trying to make a small obstacle cource

 

I am trying to have 

 

1 a trigger to start time

2 a trigger to stop time 

3 a viseble timer on scrren while the triggers ar activ...

 

 

google is not my friend :/

Share this post


Link to post
Share on other sites

1. Place a start trigger

    - on activation:

time_start = diag_tickTime;
time_running = true;
0 = [] spawn
{
   while {time_running} do
    {
      _time = (diag_tickTime - time_start) call BIS_fnc_secondsToString;
      hintSilent format ["Time: %1",_time];
      sleep 1;
   };
};

2. Place a end trigger

    - on activation:

time_running = false;

I hope that helps.

  • Like 3

Share this post


Link to post
Share on other sites

I get this error

 

 

time.png

Share this post


Link to post
Share on other sites

Remove the comments, everything behind //

Share this post


Link to post
Share on other sites

It works..... almost..... the time is way to fast!!

Share this post


Link to post
Share on other sites

Test sleep 1; instead of sleep 0.1;

Share this post


Link to post
Share on other sites

I updated my code with a more accurate solution. See above.

  • Like 1

Share this post


Link to post
Share on other sites
On 06/05/2016 at 6:58 PM, R3vo said:

1. Place a start trigger

    - on activation:


time_start = diag_tickTime;
time_running = true;
0 = [] spawn
{
   while {time_running} do
    {
      _time = (diag_tickTime - time_start) call BIS_fnc_secondsToString;
      hintSilent format ["Time: %1",_time];
      sleep 1;
   };
};

2. Place a end trigger

    - on activation:


time_running = false;

I hope that helps.

Hey, sorry for coming back onto an old thread. But im trying to use this script which is working, however, is there any way I can make a timer that shows milliseconds too? Like a race timer, for example, I want people to see there tenths. Cheers :) 

Share this post


Link to post
Share on other sites
time_start = diag_tickTime;
time_running = true;
0 = [] spawn
{
   while {time_running} do
    {
      _time = [(diag_tickTime - time_start),"MM:SS.MS"] call BIS_fnc_secondsToString;
      hintSilent format ["Time: %1",_time];
      sleep 0.001;
   };
};

 

That should work, although it's not 100% accurate.

Share this post


Link to post
Share on other sites

I am making an obstacle course and plan to have 3 courses side by side. I have a stop watch script that works well for only one stop watch at a time. Is there a way to run 3 timers at the same time with start and stop triggers for each stop watch and course.

 

1. Place a start trigger

    - on activation:

time_start = diag_tickTime; time_running = true; 0 = [] spawn {    while {time_running} do     {       _time = (diag_tickTime - time_start) call BIS_fnc_secondsToString;       hintSilent format ["Time: %1",_time];       sleep 1;    }; };

2. Place a end trigger

    - on activation:

time_running = false;

Share this post


Link to post
Share on other sites
2 hours ago, imager6 said:

I am making an obstacle course and plan to have 3 courses side by side. I have a stop watch script that works well for only one stop watch at a time. Is there a way to run 3 timers at the same time with start and stop triggers for each stop watch and course.

 

1. Place a start trigger

    - on activation:

time_start = diag_tickTime; time_running = true; 0 = [] spawn {    while {time_running} do     {       _time = (diag_tickTime - time_start) call BIS_fnc_secondsToString;       hintSilent format ["Time: %1",_time];       sleep 1;    }; };

2. Place a end trigger

    - on activation:

time_running = false;

when i automated my competition shooting mission, i set the starting time and final time as variables on the timer itself. Set an action or trigger that fires a loop(if you need to see the time displayed continually), or set the start time and end time and subtract them to see the total time(more accurate than a loop timer unless you perform checks every 5 seconds or so to set the time to the proper time). what you could do is set the start time on the timer right as the script starts/trigger activates and start your loop. have a local variable be your current time. every 5 seconds, get the current time with "time" and subtract start time from it, then set your current time varaible to equal it. you can run multiple timers at once but keep in mind a hint will get overwritten with each new hint

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

×