JG Docs
Advanced Garages

Custom Fuel System

If we don't support your fuel system out of the box, you can add your own.

  1. Go to the framework folder, and open cl-functions.lua
  2. Find the VehicleGetFuel and VehicleSetFuel functions, which should look like this:
function Framework.Client.VehicleGetFuel(vehicle)
  if (Config.FuelSystem == "LegacyFuel" or Config.FuelSystem == "ps-fuel" or Config.FuelSystem == "lj-fuel" or Config.FuelSystem == "cdn-fuel" or Config.FuelSystem == "hyon_gas_station") then
    return exports[Config.FuelSystem]:GetFuel(vehicle)
  elseif Config.FuelSystem == "ox_fuel" then
    return GetVehicleFuelLevel(vehicle)
  else
    return 65 -- or set up custom fuel system here...
  end
end

function Framework.Client.VehicleSetFuel(vehicle, fuel)
  if (Config.FuelSystem == "LegacyFuel" or Config.FuelSystem == "ps-fuel" or Config.FuelSystem == "lj-fuel" or Config.FuelSystem == "cdn-fuel" or Config.FuelSystem == "hyon_gas_station") then
    exports[Config.FuelSystem]:SetFuel(vehicle, fuel)
  elseif Config.FuelSystem == "ox_fuel" then
    Entity(vehicle).state.fuel = fuel
  else
    -- Setup custom fuel system here
  end
end
  1. Inside the VehicleGetFuel function, within the else block where it says

    return 65 -- or set up custom fuel system here...

    replace it with your custom get fuel level code. Remember to rename the vehicle entity variable to vehicle if your code snippet has it named differently.
  2. Do the same inside the VehicleSetFuel function, replacing the line that says

    -- Setup custom fuel system here

    with the set fuel level function of your fuel script. The vehicle entity variable is named vehicle and the fuel level is named fuel - again, make sure to rename these if they're named differently in the snippet you're using.
  3. Make sure that in the Configurator or config.lua you have set the Fuel system to None.