Gas Stations·exports

Exports

DS-GasStations exposes two client-side exports for reading and writing a vehicle's fuel level. Call them from any other client script.

GetFuel

client

Returns the current fuel level of a vehicle, in the 0–100 range tracked by the script.

Signature

Lua
exports['DS-GasStations']:GetFuel(vehicle)

Parameters

NameTypeDescription
vehiclenumberThe vehicle entity handle.

Returns

number

The current fuel level (0–100).

Example

Lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
local fuel = exports['DS-GasStations']:GetFuel(vehicle)
print(('Current fuel: %.1f'):format(fuel))

SetFuel

client

Overrides a vehicle's fuel level. Values are clamped to the 0–100 range. When fuel is set to 0 the engine is automatically turned off; raising it above zero turns the engine back on.

Signature

Lua
exports['DS-GasStations']:SetFuel(vehicle, amount)

Parameters

NameTypeDescription
vehiclenumberThe vehicle entity handle.
amountnumberThe new fuel level (0–100).

Example

Lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
exports['DS-GasStations']:SetFuel(vehicle, 50)

Still stuck?

Open a ticket in our Discord and we'll help you out.

Join Discord →
Gas Stations · Exports — Documentation