> For the complete documentation index, see [llms.txt](https://fantasy-scripts.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fantasy-scripts.gitbook.io/docs/gas-pumps/exports.md).

# Exports

## Exports

A vehicle's fuel is a number from **0 to 100** — how full the tank is, not litres.

fs-fuel also keeps it on the vehicle itself, where any script can read it without asking:

```lua
local fuel = Entity(vehicle).state.fuel
```

***

### Client

Use these in a player's game: garages, HUDs, vehicle menus.

#### GetFuel

How full a vehicle is.

```lua
local fuel = exports['fs-fuel']:GetFuel(vehicle)
```

| Argument  | Type   |             |
| --------- | ------ | ----------- |
| `vehicle` | number | The vehicle |

**Returns** `number` — 0 to 100.

#### SetFuel

Set how full a vehicle is.

```lua
exports['fs-fuel']:SetFuel(vehicle, 100.0)
```

| Argument  | Type   |             |
| --------- | ------ | ----------- |
| `vehicle` | number | The vehicle |
| `fuel`    | number | 0 to 100    |

**Returns** `boolean` — `true` if the value was taken.

{% hint style="warning" %}
**From a player's game, SetFuel can only give a vehicle its first fuel, or lower it.**

The gauge changes at once, but the server only keeps the new level if the vehicle has no fuel level yet — a garage handing a car out — or if it is lower than before. A player's game is never allowed to fill a tank for free, or cheaters could do the same.

To **add** fuel for real (a jerry can, a mechanic, an admin command), use the server exports below.
{% endhint %}

Garages that call `SetFuel` right after spawning a vehicle work as they always did, because a freshly spawned vehicle has no fuel level yet.

#### AddFuel

Add to, or with a negative amount take from, a vehicle's fuel.

```lua
exports['fs-fuel']:AddFuel(vehicle, -10.0)
```

| Argument  | Type   |                                                       |
| --------- | ------ | ----------------------------------------------------- |
| `vehicle` | number | The vehicle                                           |
| `amount`  | number | How much to add, out of 100. Negative takes fuel away |

**Returns** `boolean`. The same rule as `SetFuel` applies: from a player's game, only taking fuel away is kept.

#### GetTankSize

How many litres a full tank of this vehicle holds.

```lua
local litres = exports['fs-fuel']:GetTankSize(vehicle)
```

| Argument  | Type   |             |
| --------- | ------ | ----------- |
| `vehicle` | number | The vehicle |

**Returns** `number` — litres, from `Config.Tanks`.

***

### Server

Use these on the server. They always take effect.

#### GetFuel

```lua
local fuel = exports['fs-fuel']:GetFuel(vehicle)
```

**Returns** `number` — 0 to 100.

#### SetFuel

```lua
exports['fs-fuel']:SetFuel(vehicle, 100.0)
```

| Argument  | Type   |                                  |
| --------- | ------ | -------------------------------- |
| `vehicle` | number | The vehicle entity on the server |
| `fuel`    | number | 0 to 100                         |

**Returns** `boolean`.

#### AddFuel

```lua
exports['fs-fuel']:AddFuel(vehicle, 25.0)
```

| Argument  | Type   |                                                       |
| --------- | ------ | ----------------------------------------------------- |
| `vehicle` | number | The vehicle entity on the server                      |
| `amount`  | number | How much to add, out of 100. Negative takes fuel away |

**Returns** `boolean`. The level never goes below 0 or above 100.

***

### Examples

#### A garage spawning a car with the fuel it was parked with

```lua
-- client
local vehicle = CreateVehicle(model, coords.x, coords.y, coords.z, heading, true, false)
exports['fs-fuel']:SetFuel(vehicle, savedFuel)
```

#### A jerry can that adds 20 to the tank

```lua
-- server
RegisterNetEvent('myscript:useJerryCan', function(netId)
    local vehicle = NetworkGetEntityFromNetworkId(netId)
    if vehicle ~= 0 then
        exports['fs-fuel']:AddFuel(vehicle, 20.0)
    end
end)
```

#### Saving a vehicle's fuel when it is parked

```lua
-- client
local fuel = exports['fs-fuel']:GetFuel(vehicle)
TriggerServerEvent('mygarage:park', NetworkGetNetworkIdFromEntity(vehicle), fuel)
```

#### Showing the fuel in your own HUD

```lua
-- client
local fuel = Entity(vehicle).state.fuel or exports['fs-fuel']:GetFuel(vehicle)
```

{% hint style="info" %}
**fs-hud** finds fs-fuel by itself and needs no change.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://fantasy-scripts.gitbook.io/docs/gas-pumps/exports.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
