FearlessStudios

Exports

Connect a garage, HUD, price display, or custom integration to FS-Fuel.

This page is for developers connecting other resources. Normal installation is covered in Install & configure.

Fuel level

These are client exports. Pass a vehicle entity handle, not its network ID. Amounts are percentages from 0 to 100, not gallons or kWh.

local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
if vehicle ~= 0 then
    local fuel = exports['FS-Fuel']:GetFuel(vehicle)
    exports['FS-Fuel']:SetFuel(vehicle, 50.0)
end

GetFuel returns the current level. SetFuel changes it; validate your input as a finite number between 0 and 100 before calling it. Do not rely on SetFuel to clamp out-of-range input.

FS-Fuel uses GTA's vehicle fuel-level storage. A garage that persists vehicles must save and restore that value itself. Electric vehicles share this storage, so fuel-compatible garages and HUDs can use the same percentage.

Vehicle fuel type and electric vehicles

Also available on the client:

local fuelType = exports['FS-Fuel']:GetVehicleFuelType(vehicle)
local electric = exports['FS-Fuel']:IsVehicleElectric(vehicle)
local charge = exports['FS-Fuel']:GetCharge(vehicle)
local changed = exports['FS-Fuel']:SetCharge(vehicle, 80.0)
ExportResult
GetVehicleFuelType(vehicle)gasoline, diesel, electric, or nil when detection is unavailable.
IsVehicleElectric(vehicle)true for electric, false for non-electric, or nil when detection is unavailable.
GetCharge(vehicle)Battery percentage, or nil for a vehicle not identified as electric.
SetCharge(vehicle, amount)true when updated; false for invalid input or a non-electric vehicle. Finite numeric values are clamped to 0-100.

Station prices

These exports work on the client and server. Pass the station's position for its current regional price. With no position, they return the Los Santos/default price. The optional second argument selects diesel; omitting it returns regular gasoline pricing.

local position = vector3(2005.0, 3773.0, 32.0)
local regular = exports['FS-Fuel']:GetFuelPrice(position)
local diesel = exports['FS-Fuel']:GetFuelPrice(position, 'diesel')
local display = exports['FS-Fuel']:GetFuelPriceDisplay(position, 'diesel')

-- With the default Sandy settings and no automatic adjustment:
-- regular = 6.079
-- diesel = 8.129
-- display.price = 8.129
-- display.main = '8.12'
-- display.fractionalDigit = 9
-- display.fraction = '9/10'
-- display.text = '$8.12 9/10'

These exports quote liquid fuel per US gallon. They do not return electricity prices; the electricity tariff is Config.Electric.PricePerKWh. Quotes include the fixed 9/10-cent ending and any current automatic adjustment. A sale in progress keeps its locked price.

Price-change events

The client event FS-Fuel:priceChanged supplies the new Los Santos regular base price. The server event FS-Fuel:server:priceChanged supplies the new and previous base price. Regional and diesel displays should call their price export again with their own coordinates and grade.

-- Client-side example for a custom diesel sign.
local signPosition = vector3(2005.0, 3773.0, 32.0)
AddEventHandler('FS-Fuel:priceChanged', function()
    local display = exports['FS-Fuel']:GetFuelPriceDisplay(signPosition, 'diesel')
    -- Update your own sign UI with display.main and display.fraction.
end)

Request the initial quote when your resource starts as well. FS-Fuel's included signs already handle updates automatically.

Custom integrations

For an unsupported money system, select Config.Integrations.money = 'custom' and edit dist/server/integrations/money.lua. Follow the function contracts at the top of that editable file. Payments run on the server: a successful removal must return true only after the money was removed, and a failed removal must leave the balance unchanged.

Temporary payment holds also require a working refund function and a stable account identifier. Test both completed and interrupted sales, including concurrent nozzle connections.

For an unsupported notification system, edit dist/client/integrations/notifications.lua. Both integration files remain editable in the purchased resource; preserve your changes when updating.