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
clientReturns the current fuel level of a vehicle, in the 0–100 range tracked by the script.
Signature
Lua
exports['DS-GasStations']:GetFuel(vehicle)Parameters
| Name | Type | Description |
|---|---|---|
| vehicle | number | The 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
clientOverrides 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
| Name | Type | Description |
|---|---|---|
| vehicle | number | The vehicle entity handle. |
| amount | number | The new fuel level (0–100). |
Example
Lua
local vehicle = GetVehiclePedIsIn(PlayerPedId(), false)
exports['DS-GasStations']:SetFuel(vehicle, 50)