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



KillTimer bug. - TheSy - 29.04.2014

Hello!

I have a bug with my timer.

Hello!

I have a bug with my timer.

I use a timer for my km-car system.

When the player gets driver I do this:

pawn Код:
Timer_KM[playerid] = SetTimerEx("TimerKM", 500, true, "f", playerid);
And in my OnPlayerExitVehicle I do this:

pawn Код:
KillTimer(Timer_KM[playerid]);
But it does not work:

My timer I put a SendClientMessage with a format that tells me the number of kilometers, except that when I leave the vehicle SendClientMessage still appears ...

Thx !!


AW: KillTimer bug. - Macronix - 29.04.2014

Show us your "TimerKM" code please.


Re : KillTimer bug. - TheSy - 29.04.2014

pawn Код:
public TimerKM(playerid)
{
    new vid = GetPlayerVehicleID(playerid);
    CarInfo[vid][Metres] += (vitesse[playerid]*10)/36;
    if(CarInfo[vid][Metres] > 999)
    {
        CarInfo[vid][Kilometres] += 1;
        CarInfo[vid][Metres] = 0;
    }
    format(string, sizeof(string), "M: %d - KM: %d", CarInfo[vid][Metres], CarInfo[vid][Kilometres]);
    SendClientMessage(playerid, -1, string);
    return 1;
}



Re: KillTimer bug. - iZN - 29.04.2014

Why don't you just put that to OnPlayerUpdate? Or to a global timer.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) // if the player is in vehicle?
    {
        // Show them speed information
        new vid = GetPlayerVehicleID(playerid);
        CarInfo[vid][Metres] += (vitesse[playerid]*10)/36;
        if(CarInfo[vid][Metres] > 999)
        {
            CarInfo[vid][Kilometres] += 1;
            CarInfo[vid][Metres] = 0;
        }
        format(string, sizeof(string), "M: %d - KM: %d", CarInfo[vid][Metres], CarInfo[vid][Kilometres]);
        SendClientMessage(playerid, -1, string);
    }
    return true;
}



Re : Re: KillTimer bug. - TheSy - 29.04.2014

Quote:
Originally Posted by iZN
Посмотреть сообщение
Why don't you just put that to OnPlayerUpdate? Or to a global timer.

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) // if the player is in vehicle?
    {
        // Show them speed information
        new vid = GetPlayerVehicleID(playerid);
        CarInfo[vid][Metres] += (vitesse[playerid]*10)/36;
        if(CarInfo[vid][Metres] > 999)
        {
            CarInfo[vid][Kilometres] += 1;
            CarInfo[vid][Metres] = 0;
        }
        format(string, sizeof(string), "M: %d - KM: %d", CarInfo[vid][Metres], CarInfo[vid][Kilometres]);
        SendClientMessage(playerid, -1, string);
    }
    return true;
}
OnPlayerUpdate would use more resources than if I use a timer and then I kill right?


AW: KillTimer bug. - Macronix - 29.04.2014

Then put it in a global timer with a player loop.


Re: KillTimer bug. - Luis- - 29.04.2014

Why have you made the timer to use a float value instead of an integer?
pawn Код:
Timer_KM[playerid] = SetTimerEx("TimerKM", 500, true, "f", playerid);
should be this
pawn Код:
Timer_KM[playerid] = SetTimerEx("TimerKM", 500, true, "d", playerid);



Re: Re : Re: KillTimer bug. - iZN - 29.04.2014

Quote:
Originally Posted by TheSy
Посмотреть сообщение
OnPlayerUpdate would use more resources than if I use a timer and then I kill right?
I don't think. Plus, they're far better than using many unique timers for players and you can't kill, also don't need to kill that.


Re: KillTimer bug. - Pottus - 29.04.2014

I would agree OPU is the way to go here yes it will use a bit more resources but your not really going to notice and your speedo will look nice and smooth.


Re : KillTimer bug. - TheSy - 29.04.2014

By cons when I'm 50 KM/H meter moving as fast as when I'm 100 KM/H, you know not how to do?