The timers are bugged?
#1

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)