Skip to content

Exports ​

What other resources may rely on. Money is integer cents everywhere (3264 = $32.64); only np_payments and the framework accounts see whole dollars. Every table an export returns is a plain copy.

Server exports ​

server

Server exports answer nil (or {}) until np_fuel is ready (np_fuel:server:ready).

Export Returns
GetStation(id) StationView or nil
GetStations() StationView[], every station
GetStationAt(coords) The station whose radius contains coords, or nil
GetNearestStation(coords, maxDistance?, fuel?) The nearest station (that has fuel in stock, when given) and its distance, or nil
GetPrice(stationId, fuel) Price per unit in cents, or nil when the station does not sell that fuel
GetStock(stationId, fuel) { litres, capacity, level (0..100), contaminated, grid } or nil. Grid stations (EV) answer litres = -1, grid = true
AddStock(stationId, fuel, litres, reason?) New stock in litres (capped at the capacity), or nil. For another resource that delivers fuel; written to the ledger
GetFuelTypes() { { id, label, unit, price, tint, icon } } in display order
GetVehicleProfile(class, model) { tank, consumption, fuel, none } of a GTA class (0..22) and model spawn name
GetFuel(vehicle) Fuel 0..100 of a vehicle (entity handle, else net id), or nil
SetFuel(vehicle, percent, fuelType?) Sets the fuel (state bag and persistence), trusted: any value. A fuelType (or 0 %) also cleans the tank (contamination 0, the mechanic's drain). Returns the new value, or nil. A raise fires refueled with via = 'script'
GetFuelType(vehicle) 'petrol', 'premium', 'diesel', 'kerosene' or 'electric': what is in the tank
GetStationOwner(stationId) { identifier, name } of the owning character, or nil (brand station or unknown)
GetStationBalance(stationId) Company balance in cents, or nil (unknown station)
AddStationBalance(stationId, cents, reason) New balance in cents. Negative amounts withdraw (never below 0, else nil). Written to the ledger (stations.external) and the owner panel's feed
CreateOrder(stationId, fuel, litres, opts?) Delivery order id, or nil, err. See below
GetOrders(filter?) Open delivery orders { { id, station, fuel, litres, remaining, payout, status, source, createdAt, expiresAt } } (payout = fee in cents per litre). filter = { station?, fuel?, status? = 'open' | 'taken' | 'all' }

np_shops calls these for a linked pair (a station and its forecourt shop as one business). They answer only while np_shops runs; other resources can read them too.

Export Returns
GetLinkedShop(stationId) np_shops shop id of the station's forecourt shop, or nil
GetLinkedStation(shopId) { id, name, brand, owner?, ownerName?, forSale, salePrice, split } of the station a shop is linked with, or nil. salePrice = the bundle price in cents (0 when not for sale). split = true: station and shop had different owners when they were linked, so only pay inside is shared
GetLinkBalance(shopId) The shared company balance in cents (the station's balance), or nil (not linked, or split)
MoveLinkBalance(shopId, cents, kind, opts?) New shared balance in cents, or nil, err. Books shop money into the station's balance with the ledger kind shop.<kind> (sale, refund, wage, commission, wholesale, deposit, withdraw, robbery, insurance, purchase, tax, npc_margin). opts = { actor, ref, note, allowNegative }. A withdrawal below 0 answers insufficient_funds unless allowNegative. Errors: not_linked, invalid_amount, invalid_params
SetLinkStaff(shopId, identifier, name, role) true or nil, err. A hire, a role change ('manager' | 'employee') or a firing (role = nil) at the shop, mirrored into the station's staff. The same role again does nothing. Errors: not_linked, invalid_params
OpenStationScreen(src, stationId, screen?) true. Opens np_fuel's buy screen ('buy'), owner panel ('owner') or whatever fits (nil) for that player
GetFuelBills(src, shopId?) The player's open pay inside bills { { id, station, stationName, pump, fuel, fuelLabel, litres, cents, dollars, plate, at, dueAt } } (dollars = what the counter charges). With shopId: only the bills of the station linked with that shop
PayFuelBill(src, billId, method?) Pays a bill (yields: the np_payments sheet opens, same merchant and lines as a prepay at the pump). { ok = true, cents, dollars, method } or nil, err (unknown_bill, too_far when the player is not at that station, or a payment code). Credits the station, writes the ledger row and hands over the fuel_receipt
lua
-- server: which shop belongs to Grove Street, and what does the pair hold?
local shopId = exports.np_fuel:GetLinkedShop('davis_grove')
local cents = shopId and exports.np_fuel:GetLinkBalance(shopId)

CreateOrder ​

lua
local id, err = exports.np_fuel:CreateOrder(stationId, fuel, litres, {
  payoutCents = 25,     -- driver's fee per litre
  source = 'script',    -- 'script' (the brand pays) | 'owner' (escrowed from the company account)
  by = identifier,      -- who ordered
  hours = 12,           -- expiry
})

Owner orders escrow litres × (wholesale + fee) from the station's company balance (refunded for undelivered litres); script orders are paid by the brand. Errors: unknown_station, fuel_not_sold, not_available (grid / EV), order_size, order_too_big (more than the tank's free room minus open orders), station_unowned, station_funds, invalid_amount, busy (another order for that tank is being written right now: try again).

StationView ​

lua
StationView = {
  id, kind = 'fuel' | 'ev' | 'air' | 'marine', brand, name, district, coords, radius, fillPoint, chargers, blip,
  owned, ownerName, forSale, salePrice,
  fuels = { { id, price, level, available, grid } },   -- price in cents per unit, level 0..100
}

A station view never carries the owner identifier or the balance (use GetStationOwner / GetStationBalance).

Client exports ​

client

Export Returns
GetCurrentStation() StationView of the station the player stands in, or nil
GetStations() StationView[] as the client knows them (prices, stock levels)
GetFuel(vehicle) Fuel 0..100 (the driver's live level, else the state bag; bicycles 100)
SetFuel(vehicle, percent) Asks the server to set it; returns true when sent. Lowering always works; raising only right after spawn for a plate np_fuel has no level for (vehicle shops, job spawns), or always with Config.Vehicles.compatCanAdd = true
GetFuelType(vehicle) Fuel type in the tank
GetVehicleFuelInfo(vehicle) { percent, litres, tank, fuelType, contaminated, profile }
GetTankLitres(vehicle) Tank size in litres (kWh for EVs), 0 for vehicles without fuel

State bags ​

lua
Entity(veh).state.fuel     -- 0..100, replicated (ox_fuel compatible)
Entity(veh).state.npFuel   -- { type = fuel in the tank, contaminated = 0..1, class, tank }

Only the server writes them. A client script that writes fuel itself is treated like a compat SetFuel (see Bridges → Other fuel resources).

Examples ​

lua
-- server: a mechanic drains a wrongly filled tank and fills it with the right fuel
exports.np_fuel:SetFuel(vehicle, 0, 'petrol')

-- server: a fuel price board
for _, s in ipairs(exports.np_fuel:GetStations()) do
  for _, f in ipairs(s.fuels) do print(s.name, f.id, f.price / 100) end
end

-- server: a business resource pays a station's rent from its company account
exports.np_fuel:AddStationBalance('davis_grove', -50000, 'rent')

-- client: show the range on a custom HUD
local info = exports.np_fuel:GetVehicleFuelInfo(GetVehiclePedIsIn(PlayerPedId(), false))
if info then print(('%.0f / %d l'):format(info.litres, info.tank)) end