Skip to main content

BenzyFuel — Exports

Every export other resources can call, each with a ready-to-paste example.

Fuel is stored as a percentage (0–100). Server exports address a vehicle by its network id (so the same call works from any client or the server); client exports take a vehicle entity handle. GetFuel / SetFuel deliberately use the fuel-export names + shape most HUDs already expect, so they read BenzyFuel's fuel with no changes.


Client exports

GetFuel(vehicle) → number (0–100). The vehicle's current fuel.

local fuel = exports.BenzyFuel:GetFuel(GetVehiclePedIsIn(PlayerPedId(), false))

SetFuel(vehicle, pct) — set the vehicle's fuel (0–100). Syncs to everyone when you network-own the vehicle; for a vehicle you don't own it routes through the server, which only accepts fuel raises (rollbacks / consumption are written server-side).

exports.BenzyFuel:SetFuel(veh, 75.0)

GetFuelVolume(vehicle) → number. The current fuel as a volume in the configured unit, computed from Config.TankCapacity (not the per-vehicle handling capacity used for pricing/dispensing).

local gallons = exports.BenzyFuel:GetFuelVolume(veh)

IsFueling() → boolean. Is the local player mid-fuel (nozzle out, or pouring a jerry can)? Useful to gate other actions.

if exports.BenzyFuel:IsFueling() then return end

Notify(kind, title, message, duration) — raise a BenzyFuel notification (routed by BenzyBridge to whatever notification system it resolves). kind is 'success' | 'error' | 'info'.

exports.BenzyFuel:Notify('info', 'Fuel', 'Tank is getting low.')

Server exports

GetFuel(netId) → number (0–100) or nil. The vehicle's fuel, or nil if it has never been fueled/driven.

local fuel = exports.BenzyFuel:GetFuel(netId)

SetFuel(netId, pct) → number or nil. Set the fuel (0–100); returns the clamped value written, or nil if the vehicle is gone.

exports.BenzyFuel:SetFuel(netId, 100.0)

AddFuel(netId, pct) → number or nil. Add (or, with a negative value, remove) fuel; returns the new level.

exports.BenzyFuel:AddFuel(netId, 25.0)

GetFuelVolume(netId) → number or nil. The current fuel as a volume in the configured unit.

local litres = exports.BenzyFuel:GetFuelVolume(netId)

GetPricePerUnit() → number. The configured price of one gallon/litre.

local price = exports.BenzyFuel:GetPricePerUnit()

GetUnit() → string. 'gallons' or 'litres'.

local unit = exports.BenzyFuel:GetUnit()

GetCurrency(){ symbol, code, position }. The configured currency.

local cur = exports.BenzyFuel:GetCurrency() -- { symbol = '$', code = 'USD', position = 'left' }

QuoteCost(volume) → number. The whole-number amount a given volume would be charged.

local cost = exports.BenzyFuel:QuoteCost(12.5)

GiveJerryCan(src, fuelUnits?)true. Give a player a can (defaults to a full one). Handy for shops/admin.

exports.BenzyFuel:GiveJerryCan(source) -- a full can
exports.BenzyFuel:GiveJerryCan(source, 5.0) -- a can with 5 units

GetPlayerJerryCan(src) → number. How much fuel the player's can holds (0 = no can).

local canFuel = exports.BenzyFuel:GetPlayerJerryCan(source)