KillTimer bug.
#1

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 !!
Reply
#2

Show us your "TimerKM" code please.
Reply
#3

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

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

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

Then put it in a global timer with a player loop.
Reply
#7

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

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

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.
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)