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

# Flatbed

**Energy Flatbed** turns the Energy Shop flatbed trucks into working tow trucks: the bed **slides back and tilts down to the ground**, and a **cable winch** pulls the car up onto the bed, centered and straight, ready to be secured and carried.

{% hint style="danger" %}
**Works only with the Energy Shop trucks listed below.** Each truck needs a converted model, its own bed prop and its measurements in the config, so trucks from other creators are not supported.
{% endhint %}

## Highlights

* 🛻 **Animated bed**: slides back and tilts until the rear touches the ground. The angle is calculated for each truck and for the ground under it.
* 🪝 **Real winch**: take the hook in your hand (10 m of cable), attach it to the front or the rear of any empty car, even beside the truck, and start the winch. The car follows a calculated path to the center of the bed and stops right behind the headboard.
* ⚙️ **Winch motor on the bed**: the drum turns with the cable and fills up as the cable winds in.
* 🔒 **Secure the car**: lock the car on the bed and raise the bed with it.
* 🔊 **3D sounds**: hydraulic bed and electric winch, positioned in the world.
* 🧭 **Clean UI**: key panel and notifications, accent color configurable in RGB.
* 🌍 **10 languages**: en, pt-br, es, fr, de, it, nl, pl, ru, tr.
* 👮 **Permissions**: ESX, QBCore, Qbox (job + grade + on duty) and vRP / Creative (permission or group), auto-detected. Standalone: everyone can use it.
* ⚡ **Optimized**: \~0.00 ms when no truck is near.

## Supported trucks

Only these Energy Shop trucks are supported. Each pack carries its own bed, so you only get the trucks you own.

### Vehicle packs

| Pack                   | Truck (spawn name) |
| ---------------------- | ------------------ |
| Veh Mechanic           | `energyrampamec`   |
| Veh Mechanic V2        | `mtlscv3`          |
| Veh Mechanic V4        | `caracaraptorfb`   |
| Veh Police V3          | `mtlscpol`         |
| Veh Sheriff's          | `mtlscsh`          |
| Veh Los Santos Customs | `flattruck`        |

### Mechanic maps (vehicles included with the map)

| Map                     | Truck (spawn name)  |
| ----------------------- | ------------------- |
| GearHead                | `energyguinchogh`   |
| Liberty Customs         | `energyguincholb`   |
| LS Customs              | `energyguincholsc`  |
| Mosley Auto Service     | `Eguinchomosley`    |
| Over Speed              | `Eguinchoover`      |
| Ride Out Customs        | `energyguinchoride` |
| SRT Motors              | `Eguinchosrt`       |
| Stop Car                | `Kguinchomec`       |
| Top Gear                | `energyguinchotop`  |
| Underground Performance | `energyguinchouc`   |
| Evo Motors              | `Eguinchoevo`       |
| Fast Customs            | `Eguinchofast`      |
| West Coast Garage       | `energyguinchowcg`  |

## Installation

1. Drop `energy_flatbed-props` and `energy_flatbed-script` in your resources folder.
2. In `server.cfg`, start them **before** the vehicle packs:

```
ensure energy_flatbed-props
ensure energy_flatbed-script

ensure energy_vehmecv4
ensure energy_vehmecv5
# ...your other truck packs
```

3. **Start the server.** The console shows a red warning: the script switched each truck pack to its own version.
4. **Restart the server one more time.** That's it.

{% hint style="warning" %}
**You need to restart the server twice, only the first time.** On the first start the script installs its version of each truck pack, but the server has already announced the old files to players, so until the second restart the trucks spawn **floating**. After the second restart everything works and you never need to do it again.

The same one-time restart happens when you add a new truck pack, update a pack, or remove the script. The console always tells you with a red warning.
{% endhint %}

### How the truck packs work

Every supported pack has a `flatbed` folder with **two versions of the truck**:

* **With bed collision** (original): used when the script is **not** installed. Buyers who don't have the script don't need to do anything.
* **Without bed collision**: used by the script, because the bed becomes an animated prop with its own collision.

The script picks the right version automatically on server start. **Never delete the `flatbed` folder** of a pack.

{% hint style="info" %}
If you remove the script, the packs switch back to the original trucks by themselves and ask for one server restart (red warning in the console).
{% endhint %}

## How to use (in game)

All actions are done **on foot**, next to the truck. The key panel on the right shows what you can do.

| Key   | Action                                                                                         |
| ----- | ---------------------------------------------------------------------------------------------- |
| **G** | Lower / raise the bed                                                                          |
| **E** | Take / store the hook, attach / release the hook on a car, secure / release the car on the bed |
| **H** | Start / stop the winch                                                                         |

1. Stop the truck and get out. Press **G** to lower the bed.
2. Press **E** at the back of the bed to take the hook (10 m of cable).
3. Walk to the front or the rear of an **empty** car and press **E** to attach the hook.
4. Press **H** to start the winch. The car is pulled to the center of the bed and stops behind the headboard.
5. Press **E** to secure the car on the bed, then **G** to raise the bed.
6. To unload, lower the bed with **G** and press **E** to release the car.

Players can change the keys in **Settings > Key Bindings > FiveM**.

## Configuration (`config.lua`)

| Option                                    | What it does                                                                                                              |
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `Config.Locale`                           | Language: `en`, `pt-br`, `es`, `fr`, `de`, `it`, `nl`, `pl`, `ru`, `tr`.                                                  |
| `Config.UIColor`                          | UI accent color in RGB, e.g. `{ 56, 173, 255 }`.                                                                          |
| `Config.Framework`                        | `auto` (default) or force `qbox`, `qbcore`, `esx`, `vrp`, `standalone`.                                                   |
| `Config.Permission`                       | Who can use the flatbed: `everyone`, `jobs` (job = minimum grade), `onDuty` (QBCore/Qbox), `vrp` (permissions or groups). |
| `Config.Keys`                             | Default keys for the bed, hook and winch.                                                                                 |
| `Config.SlideTime` / `Config.TiltTime`    | Seconds the bed takes to slide back and to tilt down.                                                                     |
| `Config.HookRange`                        | Cable length in meters (default 10).                                                                                      |
| `Config.WinchSpeed`                       | Speed of the car while the winch pulls it.                                                                                |
| `Config.WinchVolume` / `Config.BedVolume` | Sound volumes (0 to 1).                                                                                                   |
| `Config.TruckMaxSpeedDown`                | Max truck speed while the bed is lowered.                                                                                 |

`Config.Beds` and `Config.Trucks` hold the measurements of each truck. Don't change them unless you know what you are doing.

### Permissions

* **ESX / QBCore / Qbox**: list the jobs and the minimum grade in `Config.Permission.jobs`. Set `onDuty = true` to require duty on QBCore/Qbox.
* **vRP / Creative**: list the permissions or groups in `Config.Permission.vrp`.
* **Standalone**: everyone can use it. To restrict it, edit `Framework.standalone` in `server/framework.lua`.
* `everyone = true` lets any player use it on any framework.

## Commands

| Command      | What it does                                                          |
| ------------ | --------------------------------------------------------------------- |
| `/efb_reset` | Near a truck: releases a stuck hook, cable or winch.                  |
| `/efb_debug` | Near a truck: prints the truck state in the F8 console (for support). |

## FAQ

<details>

<summary>Does it work with trucks from other creators?</summary>

No. It only works with the Energy Shop trucks listed above. Each truck needs a converted model, its own bed prop and its measurements in the config.

</details>

<details>

<summary>The truck spawns floating in the air</summary>

The server was not restarted after the script switched the truck version. Restart the server once more. This only happens on the first start after installing the script, adding or updating a pack, or removing the script.

</details>

<details>

<summary>I don't see the key panel near the truck</summary>

Check `Config.Permission`: your job or group is not allowed. You also need to be on foot (not inside a vehicle).

</details>

<details>

<summary>Do I need the script to use the truck packs?</summary>

No. Without the script the trucks work as before, with the original fixed bed and its collision.

</details>

<details>

<summary>Can I restart the script while the server is running?</summary>

Yes. The models live in `energy_flatbed-props` and in the vehicle packs, so restarting `energy_flatbed-script` does not crash anyone. Don't restart `energy_flatbed-props` or the vehicle packs while players are using the trucks.

</details>

{% hint style="info" %}
Need help? Join our Discord: [discord.gg/PHnzjBujnE](https://discord.gg/PHnzjBujnE). The resource is licensed per customer: do not share or resell it.
{% endhint %}
