The timers are bugged? - 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: The timers are bugged? (
/showthread.php?tid=545486)
The timers are bugged? -
Metharon - 08.11.2014
- I have all recent updates of includes & plugins.
I don't understand why but i get serious problem about timers for example i have a timer for speedometer , it's simply jumps!
- Is setted to get -1 / 30 secs
Today it jumps from 99 FUEL to 86 FUEL in 4 secs?!
The code :
-
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
FuelTimer[playerid] = SetTimerEx("gSpeed_Fuel", 30000, false, "i", playerid);
return 1;
}
Function gSpeed_Fuel(playerid)
{
new vehicleid = GetPlayerVehicleID( playerid );
new playerState = GetPlayerState(playerid);
if( IsPlayerInAnyVehicle( playerid ) && Motor[vehicleid] == 1 && playerState == PLAYER_STATE_DRIVER)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(!IsPointInRangeOfPoint(x, y, z, mPosition[playerid][0], mPosition[playerid][1], mPosition[playerid][2], 0.1))
{
if( mFuel[ vehicleid ] > 0 ) mFuel[ vehicleid ] --;
FuelTimer[playerid] = SetTimerEx("gSpeed_Fuel", 30000, false, "i", playerid);
}
mPosition[playerid][0] = x;
mPosition[playerid][1] = y;
mPosition[playerid][2] = z;
}
}
And i have a killtimer on onplayerexitvehicle.
My question is :
- Can somebody teach me WHY i have that kind of bugs? is a new gamemode 13628 LN , and i have serious bugs about timers for example i had a bug on mute system
http://i.imgur.com/rj08JcK.jpg
Please , help me someone!
Re: The timers are bugged? -
M4D - 08.11.2014
Use SetTimer in OnPlayerStateChange Callback.
because OnPlayerEnterVehicle Callback Call when a player attempts to enter a vehicle and maybe player cancel entering the vehicle !
and you set a timer
if a player don't enter a vehicle, that vehicle fuel will consume.