BenzyFuel — Events
The server events other resources can listen to with AddEventHandler. They fire after a sale or refuel is finalized, so they're the right hook for station revenue, logs, achievements, or your own Discord logging. All of them are plain server events (not net events).
BenzyFuel:FuelPurchased
Fires every time a pump sale is finalized (the nozzle is returned or the session otherwise ends) — including when Config.ChargeForFuel is off, in which case paid = true and cost = 0.
Payload: { src, netId, volume, unit, cost, currency, account, paid, error }
src— the buyer's server id ·netId— the vehicle's network idvolume— units dispensed ·unit—'gallons'/'litres'cost— the whole-number amount charged ·currency—'USD'/'EUR'·account—'cash'/'bank'paid— did the charge succeed? ·error— an error code string when it didn't (e.g.'INSUFFICIENT_FUNDS','NO_MONEY_SYSTEM')
AddEventHandler('BenzyFuel:FuelPurchased', function(data)
if data.paid and data.cost > 0 then
print(('Player %s bought %.1f %s of fuel for %d'):format(data.src, data.volume, data.unit, data.cost))
end
end)
BenzyFuel:JerryCanPurchased
Fires when a player buys (or refills) a jerry can at a pump.
Payload: { src, cost, capacity }
src— the buyer's server id ·cost— the whole-number amount charged ·capacity— the can's capacity
AddEventHandler('BenzyFuel:JerryCanPurchased', function(data)
print(('Player %s bought a jerry can for %d'):format(data.src, data.cost))
end)
BenzyFuel:VehicleRefueled
Fires whenever a vehicle is topped up — from a pump or a jerry can. Use it if you care about the fuel going into a vehicle regardless of who paid (e.g. a station that only bills for pump fuel).
Payload: { netId, volume, source, src }
netId— the vehicle's network id ·volume— units addedsource—'pump'or'jerrycan'·src— the player who did it
On a failed pump charge with rollback enabled, the fuel is taken back out of the tank but this event still reports the dispensed
volume. If you need to know the charge actually succeeded, check the matchingBenzyFuel:FuelPurchased(paid = false).
AddEventHandler('BenzyFuel:VehicleRefueled', function(data)
print(('%s added %.1f units to vehicle %s via %s'):format(data.src, data.volume, data.netId, data.source))
end)
The resource also uses several internal net events to drive its own flow — these are private implementation details and may change between versions — listen to the server events above instead.