Strange bug - Speedometer & fuel update too fast.
#1

When I spawn a vehicle (any) the speedometer updates really fast and the fuel - which is set to update every 20 seconds updates in around 5. it's very strange, yet when I restart the server; (the vehicles load from mysql) and it works perfectly, can anyone see anything that might suggest why this happens?

pawn Код:
public SpeedoUpdate()
{
    for(new i = 0;i<MAX_PLAYERS;i++)
    {
        if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i))
        {
            new Float:x,Float:y,Float:z,string[24],vehicleid = GetPlayerVehicleID(i);
            if(GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                TextDrawShowForPlayer(i,speed[i]);
                TextDrawShowForPlayer(i,fuel[i]);
            }
            GetVehicleVelocity(vehicleid,x,y,z);
            format(string,sizeof(string),"~g~Speed: ~w~%d mph",floatround(floatsqroot(((x*x)+(y*y))+(z*z))*156.666667*0.641371192));
            TextDrawSetString(speed[i],string);
            format(string,sizeof(string),"~g~Fuel: ~w~%d%%",VehFuel[vehicleid]);
            TextDrawSetString(fuel[i],string);
        }
        if(!IsPlayerInAnyVehicle(i))
        {
            TextDrawHideForPlayer(i,speed[i]);
            TextDrawHideForPlayer(i,fuel[i]);
        }
    }
}
public FuelUpdate()
{
    foreach(Player, p)
    {
    for(new i = 1;i<MAX_VEHICLES;i++)
    {
        if(GetVehicleModel(i))
        {
            GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
            if(engine == 1)
            {
                if(VehFuel[i] > 0)
                {
                    VehFuel[i]--;
                    Fuel = VehFuel[i];
                }
                else if(VehFuel[pvehicle] == 0)
                {
                    EngineStartStatus[i] = 0;
                    SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
                    GameTextForPlayer(p, "~r~out of fuel", 3000, 5);
                    SendClientMessage(p, COLOUR_REALRED, "Your vehicle has run out of fuel.");
                        }
                   
                    }
                }
        }
    }
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)