Fuel System Textdraw
#1

I created a textdraw for fuel system. Everything is working fine for one player. But after driving the second vehicle, the previous value of fuel is overlapping with new one and both the values are decreasing together.

PHP код:
new fueltimer[MAX_VEHICLES]; 
PHP код:
public OnPlayerConnect(playerid)
{
    
VehicleMeter[playerid] = TextDrawCreate(498.000000140.000000" ");
    
TextDrawBackgroundColor(VehicleMeter[playerid], 255);
    
TextDrawFont(VehicleMeter[playerid], 1);
    
TextDrawLetterSize(VehicleMeter[playerid], 0.3899991.299999);
    
TextDrawColor(VehicleMeter[playerid], 0xFFFFFFFF);
    
TextDrawSetOutline(VehicleMeter[playerid], 1);
    
TextDrawSetProportional(VehicleMeter[playerid], 1);
    
    return 
1;

PHP код:
public OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
vid GetPlayerVehicleID(playerid);
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        
TextDrawShowForPlayer(playeridVehicleMeter[playerid]);
        
fueltimer[vid] = SetTimerEx("DecreaseFuel"10001"ii"playeridvid);
    }
    else
    {
        
TextDrawHideForPlayer(playeridVehicleMeter[playerid]);
        
KillTimer(fueltimer[vid]);
    }
    return 
1;

PHP код:
public OnPlayerExitVehicle(playeridvehicleid)
{
    
KillTimer(fueltimer[vehicleid]);
    
TextDrawHideForPlayer(playeridVehicleMeter[playerid]);
    return 
1;

Function:
PHP код:
public DecreaseFuel(playeridvehicleid// Decreases fuel by 0.035 (Whole fuel finishes in almost 50 minutes)
{
    new 
enginelightsalarmdoorsbonnetbootobjectivestring[128];
    
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
    if(
IsBicycle(vehicleid) == || IsValidDealershipVehicle(vehicleid) == || engine == 0)
        return 
1;
    else
    {
        if(
Vehicle[vehicleid][vFuel] <= 0)
        {
            
ToggleEngine(vehicleidVEHICLE_PARAMS_OFF);
            
SendClientMessage(playeridCOLOR_LIGHTRED"Your vehicle is out of fuel.");
            
KillTimer(fueltimer[vehicleid]);
        }
        
format(stringsizeof(string), "Fuel: %d%%"floatround(Vehicle[vehicleid][vFuel]));
        
TextDrawSetString(VehicleMeter[playerid], string);
        
Vehicle[vehicleid][vFuel] -= 0.035;
    }
    return 
1;

Reply


Messages In This Thread
Fuel System Textdraw - by JaskaranSingh - 18.04.2018, 19:21
Re: Fuel System Textdraw - by JaskaranSingh - 19.04.2018, 09:48
Re: Fuel System Textdraw - by jasperschellekens - 19.04.2018, 10:18
Re: Fuel System Textdraw - by JaskaranSingh - 19.04.2018, 16:14
Re: Fuel System Textdraw - by CodeStyle175 - 19.04.2018, 16:52
Re: Fuel System Textdraw - by Pottus - 19.04.2018, 16:57
Re: Fuel System Textdraw - by JaskaranSingh - 19.04.2018, 19:33

Forum Jump:


Users browsing this thread: 1 Guest(s)