Exports
Exports
Four client-side exports, for other resources that need to read or change a vehicle's fuel. This page documents only what actually exists in the resource.
local fuel = exports['bupa-fuel']:GetFuel(vehicle)
exports['bupa-fuel']:SetFuel(vehicle, 75.0)
local kind = exports['bupa-fuel']:GetFuelType(vehicle)
local ev = exports['bupa-fuel']:IsElectric(vehicle)| Export | Arguments | Returns |
|---|---|---|
GetFuel |
vehicle (entity handle) |
The fuel level as a number, 0.0–100.0 |
SetFuel |
vehicle, level (number) |
Nothing |
GetFuelType |
vehicle (entity handle) |
A fuel key string — 'gasoline', 'diesel', 'premium', 'electric' |
IsElectric |
vehicle (entity handle) |
true or false |
Notes
GetFuel returns 0.0 for an invalid or non-existent entity. If the vehicle has never been seen before, this is the call that rolls its Config.Consumption.SpawnFuel level and writes it to the state bag — so simply reading a fresh car's fuel is what gives it one.
SetFuel clamps to 0.0–100.0. On a networked vehicle it writes to the entity state bag, which replicates to every client; on a local one it only sets the native level. It is a percentage, not litres — for litres, multiply against the tank size for that vehicle's class.
GetFuelType resolves in the same order the pump does: the electric list, then Config.VehicleFuel.Model, then the class table, falling back to 'gasoline'.
IsElectric is shorthand for GetFuelType(vehicle) == 'electric'.
Fuel is replicated through the fuel state bag on the vehicle entity. Any resource that wants to watch fuel changes without polling can add its own AddStateBagChangeHandler('fuel', ...) rather than calling GetFuel on a loop.
Inventory item handler
bupa-fuel.useJerryCan is the ox_inventory item-use handler for the jerrycan item. You reference it from the item definition — you do not call it yourself.
client = { export = 'bupa-fuel.useJerryCan' }On QBox, QB-Core and ESX the usable item is registered internally by the resource, so no export wiring is needed there.