vehicle fuel help
#1

just to the point, is there something wrong with my code ?
pawn Код:
public FuelUpdate(){
    for(new i = 1;i<MAX_VEHICLES;i++){
        if(GetVehicleModel(i)){
            new engine,lights,alarm,doors,bonnet,boot,objective;
            GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
            if(engine == 1 && !IsVIPcar(i) || !IsASepedah(GetVehicleModel(i)) || !isGarbageCar(i) || !isDMVCar(i)){
                if(VehicleFuel[i] > 0) VehicleFuel[i]--;
                else SetVehicleParamsEx(i,0,lights,alarm,doors,bonnet,boot,objective);
            }
        }
    }
}
i tried to make some vehicle from script have infinite fuel, but the vehicle i wanted infinite fuel, they keep their fuel decreased,

sorry for bad english ..
Reply
#2

bump..
Reply
#3

I believe this will not work because if the players car is not a VIP it will continue checking the next one and it will not be a IsASepedah so it will continue on to the code the only way this would work is if that one car was all of the statements
Reply
#4

You Can Try This , Not Tested But Should Work
PHP код:
new Fuel[MAX_VEHICLES];
new 
Text:FuelTxt[MAX_PLAYERS];
forward FuelUpdate();
main()
{
  for(new 
i=0;i<MAX_PLAYERS;i++)
  {
    
//--[Fuel]
    
FuelTxt[playerid] = TextDrawCreate(0,410,"Fuel:%i%");
    
TextDrawBackgroundColor(FuelTxt[playerid],0x00000033);
    
TextDrawFont(FuelTxt[playerid],3);
    
TextDrawLetterSize(FuelTxt[playerid],0.399999,1.700000);
    
TextDrawColor(FuelTxt[playerid],0xFFFFFFFF);
    
TextDrawSetShadow(FuelTxt[playerid],3);
  }
}
public 
OnGameModeInit()
{
  
//--[Fuel]
  
for(new i=0;i<MAX_VEHICLES;i++)
  {
    
Fuel[i] = 100;
  }
  return 
1;
}
public 
FuelUpdate()
{    
  for(new 
i=0;i<MAX_PLAYERS;i++)
  {
    new 
vehicleid GetPlayerVehicleID(i);
    new 
engine,lights,alarm,doors,bonnet,boot,objective;
    
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);           
    if(
GetPlayerVehicleSeat(i) == 0)
    {
      if(
vehicleid == VIP)///(VIP = CreateStaticVehicle)///---[change]
      
{
         
VehicleFuel[vehicleid]++; 
      }
      else
      {               
         
VehicleFuel[vehicleid]--;
         if(
VehicleFuel[vehicleid]<= 0)
         {
           
VehicleFuel[vehicleid] = 0;
           
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
           
VehicleInfo[vehicleid][vEngine] = 0;
           
GameTextForPlayer(i,"~w~You Are Out Of ~r~Fuel~w~!",5000,4);
         }
      }
    }
    new 
string[125];
    
format(string,sizeof string,"Fuel:%i%",VehicleFuel[vehicleid]);
    
TextDrawSetString(FuelTxt[i],string);
  }
  return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)