Posts: 220
Threads: 54
Joined: Jan 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 !!
Posts: 478
Threads: 4
Joined: Jul 2010
Reputation:
0
Show us your "TimerKM" code please.
Posts: 220
Threads: 54
Joined: Jan 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;
}
Posts: 220
Threads: 54
Joined: Jan 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?
Posts: 478
Threads: 4
Joined: Jul 2010
Reputation:
0
Then put it in a global timer with a player loop.
Posts: 4,885
Threads: 57
Joined: Jun 2012
Reputation:
0
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.
Posts: 220
Threads: 54
Joined: Jan 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?