Configure the built-in fuel model
The official fuel manual describes an optional consumption model that is disabled by default. It does not include a complete gas-station or purchase system. Choose one resource to own fuel state so two systems do not repeatedly overwrite each other’s values.
Enable, inspect and tune consumption
| Native or field | Contract |
|---|---|
SET_FUEL_CONSUMPTION_STATE | Enable or disable consumption with a boolean. |
GET_FUEL_CONSUMPTION_STATE | Inspect whether consumption is enabled. |
SET_FUEL_CONSUMPTION_RATE_MULTIPLIER | Set the global multiplier; default 1. The source says negative values use zero instead. |
GET_FUEL_CONSUMPTION_RATE_MULTIPLIER | Read the global multiplier. |
fPetrolConsumptionRate | Per-vehicle handling multiplier; default 0.5 when not otherwise configured. |
fPetrolTankVolume | Tank capacity. A zero-capacity tank is treated as infinite fuel by the documented consumption check. |
GET_VEHICLE_FUEL_LEVEL / SET_VEHICLE_FUEL_LEVEL | Read or set the current amount of fuel. Tank capacity and current level are different values. |
DOES_VEHICLE_USE_FUEL | Check whether the vehicle is eligible to consume fuel when a player is inside. |
Use SET_HANDLING_FLOAT for the relevant handling configuration, or SET_VEHICLE_HANDLING_FLOAT for one vehicle, with the exact handling field name. The field can also be defined in an owned handling.meta asset. Changing one vehicle’s field does not automatically update every vehicle or persist a player’s fuel across server restarts.
Calculation and exclusions
The documented consumption calculation is:
consumption = time_step × revolutions_per_minute
× vehicle_fuel_consumption_rate_multiplier
× global_fuel_consumption_rate_multiplierFuel is not consumed with the engine off. The default 65-litre example in the manual lasts approximately 16.67 hours at idle or 2.5 hours at maximum RPM; those are illustrative default conditions, not a measurement of every modified vehicle. Tune using controlled tests rather than assuming a desired road distance maps directly to an RPM multiplier.
The source excludes vehicles containing only NPCs, bicycles (its type-12 classification), and vehicles with a zero-volume tank. Use DOES_VEHICLE_USE_FUEL instead of reproducing an incomplete model-name allowlist. An electric-looking model or custom vehicle label alone does not establish how its handling fields are configured.
A read-only client diagnostic
Declare this as a client script in a test resource. It does not change fuel, consume money or take ownership from the installed fuel provider:
RegisterCommand('docfuel', function()
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)
if vehicle == 0 or not DoesEntityExist(vehicle) then
print('Enter a vehicle before running docfuel.')
return
end
local level = GetVehicleFuelLevel(vehicle)
local capacity = GetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fPetrolTankVolume')
local rate = GetVehicleHandlingFloat(vehicle, 'CHandlingData', 'fPetrolConsumptionRate')
print(('Enabled: %s; eligible: %s; fuel: %.3f/%.3f; rate: %.3f; global: %.3f')
:format(tostring(GetFuelConsumptionState()), tostring(DoesVehicleUseFuel(vehicle)),
level, capacity, rate, GetFuelConsumptionRateMultiplier()))
end, false)Record the original global state and handling values before a deliberate tuning test. Restore them afterward through the same owner resource. Resource shutdown does not inherently reset every native value changed by a script.
Build a gas station as a separate feature
The official example models a station as coordinates plus a radius, checks vehicle position, displays fuel and capacity, and fills the tank when a control is pressed. Its client-side setter illustrates the native; it is not a secure purchase implementation.
Use the station’s validated geometry to decide whether to show a local prompt. A small radius check may be enough for a demonstration; multiple floors, nearby roads or a large forecourt can require more precise zones. Frame-dependent help text and input handling need per-frame work while the prompt is active, but expensive database calls do not.
For an actual purchase, send a bounded request identifying the intended station, vehicle and operation. On the server, validate the session, current position, vehicle identity/control policy, fuel limits and server-owned price. Debit money and record the transaction idempotently before confirming the allowed result. Never trust a client-supplied price, balance or unlimited tank capacity. See secure events and network IDs.
Holding a key should not create a fresh purchase on every frame. Use edge-triggered input or an explicit active-operation state, disable duplicate requests, and provide cancel/failure handling. Aborting a UI request does not undo a transaction already committed on the server.
Acceptance cases
Test engine on/off, idle versus driving, the global multiplier, one-vehicle handling changes, a bicycle, an NPC-only vehicle and a zero-volume tank. Verify that the existing fuel provider is not simultaneously resetting the level. For purchases, test insufficient funds, a full tank, leaving the station, vehicle deletion, owner migration, a disconnect and a repeated request ID.
Record the exact game track, build and resource versions. Native execution and consumption measurements require a client; a documentation build cannot prove fuel use, payment correctness or persistence. Keep the native demonstration separate from the production transaction system.