HELP! Timer! - 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: HELP! Timer! (
/showthread.php?tid=343006)
HELP! Timer! -
Jo0ker - 15.05.2012
[color=green][size=12pt][font=trebuchet ms]Gamemod :
AGRP
Problem :
I have made a timer for race, when race starts this timer starts, and tells you in which time you finished the race. The problem is when race is over i have puted this :
Код:
KillTimer(racevrijeme);
[size=12pt]and the problem is that timer is paused, not stoped, when I start race again timer starts from earlier point (where timer was paused -> where i puted "killtimer".
I put this code on the start off race, can anyone tell me what should i put to make it reset the timer?[/size]
Код:
racevrijeme = SetTimer("GameTicks", 500, 1);
[size=12pt]I want to make it reset, not to stop, and then start from that point? I want that every time timer starts from zero![/size]
Re: HELP! Timer! -
Face9000 - 15.05.2012
You've to add a case; when the times reachs the zero.Something like this:
pawn Код:
switch(racevrijeme[playerid])
  {
    case 0: // The timer stopped
    {
      new string[128];
      KillTimer(racevrijeme[playerid]);
      format(string, sizeof(string), "Race finished: Total time: %d",racevrijeme[playerid]);
      SendClientMessage(playerid,red,string);
    }
}
Re: HELP! Timer! -
Jo0ker - 15.05.2012
The time doesnt reaches the zero it goes from 0 to higher, not countdown it's like stopwatch.
Re: HELP! Timer! -
Face9000 - 15.05.2012
Quote:
"I want to make it reset, not to stop"
|
Is what you asked?
Re: HELP! Timer! -
Jo0ker - 15.05.2012
I'm not very good with English
I have the problem that when race is over, when player reaches last CP i have put "KillTimer", and it works, but if i want to race again, and when i start race again timer doesn't start from 0, but from time of last CP, or before i have puted "killTimer"
Re: HELP! Timer! -
Jo0ker - 16.05.2012
anyone?
AW: HELP! Timer! -
EthanR - 16.05.2012
The problem is in your Checkpoint reset code then (if you have one). Post the Checkpoint race code and somebody can help you.
Re: HELP! Timer! -
Baboon - 16.05.2012
new racevrijeme[MAX_PLAYERS];
racevrijeme[playerid] = SetTimer("GameTicks", 500, true, "d", playerid);
new raceplayercalled[MAX_PLAYERS];
So it goes every 500 ms.
Under GameTicks function just do: raceplayercalled[playerid]++;
When a player is inside the checkpoint (there is a public function for that).
destroy racevrijeme[playerid] timer and to get how many seconds it took do: raceplayercalled[playerid] = raceplayercalled[playerid]/2; Then just output raceplayercalled[playerid] in a format and voila, there is your race time.
why /2? Cus 500 ms is the half of 1000ms (= 1second). After you have done that simply make raceplayercalled[playerid] = 0; and start the timer again when the next race starts
Re: HELP! Timer! -
Jo0ker - 16.05.2012
i will try that
Re: HELP! Timer! -
Jo0ker - 17.05.2012
It works when I'm racing alone, but when somebody else races with me it kicks random number, does anybody now whats the problem?