SA-MP Forums Archive
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: Timer (/showthread.php?tid=432983)



Timer - KopeK - 25.04.2013

Hi I have this code:
Код:
forward UpdateCzasJazdy(playerid);
public UpdateCzasJazdy(playerid)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
sekundy[playerid]++;
if(sekundy[playerid] == 60)
{
minuty[playerid]++;
sekundy[playerid] = 00;
}
new str[256];
format(str, sizeof(str), "Czas Jazdy:~w~   %02d:%02d", minuty, sekundy);
TextDrawSetString(CzasJazdy[playerid], str);
}
return 1;
}
And Timer:
Код:
TimerPojazd4[playerid] = SetTimerEx("UpdateCzasJazdy", 1111, true,"i",playerid);
And the timer is killed when a player goes out of the vehicle. I have a problem with that. When a player with id 0 goes out of the vehicle a timer is killed for everyone but should only him.

Код:
KillTimer(TimerPojazd4[playerid]);
Please Help


Re: Timer - MP2 - 25.04.2013

1. Indent properly.
2. Use [ pawn ] tags not [ code ].
3. Debug your code - add prints (or client messages) in your timer to see who it's being called for.
4. If the timer is killed when the player gets out of the vehicle, why is this in your timer:

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)



Re: Timer - KopeK - 25.04.2013

So how to reapir it ? I deleted form code:
pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER){
But nothing has changed.


Re: Timer - MP2 - 25.04.2013

FOLLOW ALL THE STEPS THEN. NOT JUST A SINGLE ONE.


Re: Timer - KopeK - 25.04.2013

I follow all the steps but i don't know whats the problem :/


Re: Timer - MP2 - 25.04.2013

Have you put client messages/prints in like I said?


Re: Timer - KopeK - 25.04.2013

But where i must put it ?


Re: Timer - mamorunl - 25.04.2013

pawn Код:
TimerPojazd4[playerid] = SetTimerEx("UpdateCzasJazdy", 1111, true,"i",playerid);
Where is this piece of code placed? I have a feeling that 'playerid' is not properly defined.


Re: Timer - KopeK - 25.04.2013

I put it into:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
//Here Timer
    }else{
//Here KillTimer
}
    return 1;
}