Skip to Content

By default in GTAV and FiveM, vehicles do not consume fuel. This feature allows you to turn fuel consumption on and customize it for your needs.

Turn On/Off

Use SET_FUEL_CONSUMPTION_STATE to enable/disable fuel consumption.

How It Works

Fuel Consumption Speed

Fuel consumption is calculated by the formula:

time_step * RPM * vehicle_fuel_consumption_rate_multiplier * global_fuel_consumption_rate_multiplier

Fuel is consumed faster the more revolutions the engine does. This approximates real-world fuel consumption.

Fuel is not consumed when the engine is turned off.

By default, a 65-liter gas tank car with average fuel consumption can:

Customize Consumption Speed

To customize the global fuel consumption rate, use SET_FUEL_CONSUMPTION_RATE_MULTIPLIER. Default is 1.

To customize fuel consumption per vehicle, use SET_HANDLING_FLOAT (for all vehicles with given class) or SET_VEHICLE_HANDLING_FLOAT (for a specific vehicle) with fieldName equal to fPetrolConsumptionRate. Default is 0.5.

You can also use CodeWalker  to edit vehicle handling.meta file.

Petrol Tank Volume

To customize petrol tank volume, use SET_HANDLING_FLOAT or SET_VEHICLE_HANDLING_FLOAT with fieldName equal to fPetrolTankVolume.

Use GET_VEHICLE_FUEL_LEVEL and SET_VEHICLE_FUEL_LEVEL to get/set current fuel level.

Vehicles Without Fuel Consumption

Fuel is not consumed for:

Use DOES_VEHICLE_USE_FUEL to check if a vehicle will consume fuel.

Example: Gas Station Implementation

GasStations = { { coords = vector3(64.55, 20.4, 68.9), radius = 8 } } function IsPointInGasStation(point, gasStation) return #(point - gasStation.coords) <= gasStation.radius end function ProcessGasStationEnter(vehicle) local fuelLevel = GetVehicleFuelLevel(vehicle) local tankVolume = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fPetrolTankVolume") local message = string.format("Fuel: %.3f/%.3f liters. Press G to fill.", fuelLevel, tankVolume) AddTextEntry("CH_ALERT", message) BeginTextCommandDisplayHelp("CH_ALERT") EndTextCommandDisplayHelp(0, false, false, 200) end function ProcessGasStationFuelPurchase(vehicle) local tankVolume = GetVehicleHandlingFloat(vehicle, "CHandlingData", "fPetrolTankVolume") SetVehicleFuelLevel(vehicle, tankVolume) end function IsVehicleAtGasStation(vehicle) if not DoesVehicleUseFuel(vehicle) then return false end local coords = GetEntityCoords(vehicle) for _, station in ipairs(GasStations) do if IsPointInGasStation(coords, station) then return true end end return false end CreateThread(function() while true do Wait(0) if GetFuelConsumptionState() then local vehicle = GetVehiclePedIsIn(PlayerPedId(), false) if DoesEntityExist(vehicle) then if IsVehicleAtGasStation(vehicle) then ProcessGasStationEnter(vehicle) if IsControlPressed(0, 58) then ProcessGasStationFuelPurchase(vehicle) end end end end end end)