Question about timers.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about timers.. (
/showthread.php?tid=309806)
Question about timers.. -
Azzeto - 09.01.2012
With a timer, how would I check if their under the time, or get their time, ( For ex: A race ) so when they pass the last checkpoint it would say like You've finished the race in xxx.xxx seconds, (I'm trying to work more with timers and things.)
Re: Question about timers.. -
Sinner - 09.01.2012
Timers are used to run something after a fixed amount of time. If you want to calculate the time between 2 points you shoulden't use timers but tick counts.
For example:
pawn Код:
public OnGameModeInit() {
new tick1 = GetTickCount(); // Get the time in milliseconds (for example when he enters the checkpoint)
// Do all your stuff here
new tick2 = GetTickCount(); // Get the time again in milliseconds (for example when he enters the next checkpoint)
new difference = tick2 - tick1; // new time - old time = difference in time (example: time between checkpoints)
printf("The difference between tick1 and tick2 is %d milliseconds", difference);
}
Hope that helped