HELP! Timer!
#1

[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]
Reply
#2

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);
        }
}
Reply
#3

The time doesnt reaches the zero it goes from 0 to higher, not countdown it's like stopwatch.
Reply
#4

Quote:

"I want to make it reset, not to stop"

Is what you asked?
Reply
#5

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"
Reply
#6

anyone?
Reply
#7

The problem is in your Checkpoint reset code then (if you have one). Post the Checkpoint race code and somebody can help you.
Reply
#8

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
Reply
#9

i will try that
Reply
#10

It works when I'm racing alone, but when somebody else races with me it kicks random number, does anybody now whats the problem?
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)