Custom Fuel System
If we don't support your fuel system out of the box, it's super easy to add your own!
Go to the
frameworkfolder, and opencl-functions.luaFind the
VehicleGetFuelandVehicleSetFuelfunctions, 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
endInside the
VehicleGetFuelfunction, within theelseblock where it saysreturn 65 -- or set up custom fuel system here...replacing it with your custom get fuel level code. Remember to rename the vehicle entity variable tovehiclein case your code snippet has it named differently.Do the same inside the
VehicleSetFuelfunction replacing the line that says-- Setup custom fuel system herewith the set fuel level function of your fuel script. The vehicle entity variable is namedvehicleand the fuel level is namedfuel- again make sure to rename these if they are named differently in the snippet you are using!Make sure that in the Configurator or
config.luayou have set the Fuel system to None.
Last updated
Was this helpful?