StarvinMarvin 0 Posted July 31, 2007 hey guys! need some help here i made an obstacle course and ofcause i want to know how fast i do it so how do i create a timer that starts when i start the course and stops and shows the time when i complete it.. i know its kinda easy stuff... but easy enough to fool my brain gettin rusty.. thanks alot! Share this post Link to post Share on other sites
StarvinMarvin 0 Posted July 31, 2007 I almost got it to work by myself with this.. since (time) var is the time the mission have been running i reset it by reduceing it with its own value here at the beginning // _timer = time -time #count ?stoptimer : goto "showtime" ///here its waiting for me to finish/// ~0.1 goto "count" #showtime ///Displays the time taken from start of the script untill stoptime = true/// _timer = time hint format ["Your time: %1 ", _timer] ~8 ///here i wanted to just type hint "timer reset" but that didnt work so i had to use hint format/// hint format ["timer reset"] exit // I always get the time when the script is run.. but the second time i run the course i get the time from that run.. added to the previous run.. for ex: first run (8sec) second run (7sec + 8sec) tried several ways to reset the variable Time but either it gives me "your time = 0" the first or second run, or it still doesnt reset the timer at all. Since the scripts starts by making TIME = 0 i supposed it should reset.. but somehow it remembers my old time. im confused.. to much numbers :P someone please help. Share this post Link to post Share on other sites
.kju 3244 Posted July 31, 2007 hello StarvinMarvin try this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_start = time #count ?stoptimer : goto "showtime" ///here its waiting for me to finish/// ~0.1 goto "count" <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#showtime ///Displays the time taken from start of the script untill stoptime = true/// _end = time hint format ["Your time: %1 ", _end - _start] ~8 hint format ["timer reset"] exit no guarantee though Share this post Link to post Share on other sites
HitmanFF 6 Posted July 31, 2007 You could consider changing the waiting part to <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_start = time @stoptimer ///here its waiting for me to finish/// goto "showtime" Share this post Link to post Share on other sites
Rastavovich 0 Posted July 31, 2007 Use and .sqf and in it: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _time = 0; stoptime = false; while {!stoptime} do { Â _time = _time + 0.1; Â sleep 0.1; }; _time and use it in the main script over _timeNeeded = [] execVM "thatScript.sqf" Attention: the results might differ with very slow framerate (but that issue the other mentioned examples have as well) Edit: typo in code Share this post Link to post Share on other sites
Tankbuster 1746 Posted November 17, 2007 Does this work in multiplayer? Share this post Link to post Share on other sites