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

# Garage (cc\_garage)

Park, retrieve, transfer and sell vehicles with a 3D preview. Seven preconfigured garages including a truck yard, a marina and a hangar, an impound lot, a tow truck job and trailers for semi trucks.

**Frameworks:** ESX Legacy, QBCore, QBox (detected automatically, see Framework Bridge).

## Features

* Seven garages: Legion Square, Pillbox Hill, Airport parking, truck yard La Mesa, Marina (boats), Hangar LSIA (helicopters and planes) and the impound lot
* Vehicle class restrictions per garage, checked on the server in both directions (listing, parking, retrieving, delivery)
* 3D preview with a data sheet when taking a vehicle out
* Transfer vehicles to other players or sell them back for a share of the list price
* Paid services: bring a vehicle back to the garage remotely, repair while parked (price depends on damage)
* Remember the last parking spot and show it on the map
* Persistent vehicles (OneSync): they stay in the world when the owner logs off and are restored after a restart with fuel, engine, body, tuning, windows, doors and tyres
* Destroyed and sunk vehicles are sent to the impound lot automatically
* Tow truck job: wrecks become orders for a job, drivers are paid on delivery (optionally from the company account)
* Trailers for semi trucks (Phantom, Hauler, Packer): picked when retrieving and attached automatically
* Boats are placed on the waterline and anchored, aircraft get their landing gear lowered
* Staff peds or ground markers at each garage, blips toggleable per player
* Server exports for other scripts (`Deliver`, `Impound`, `Nearest`)

## Optional integrations

| Resource                                     | Effect                                                        |
| -------------------------------------------- | ------------------------------------------------------------- |
| cc\_keys/00%20Overview\.md)                  | Keys on retrieve, keys revoked on sale/transfer               |
| cc\_images%20(cc\_images)/00%20Overview\.md) | Vehicle images in the list; otherwise the class icon is shown |
| cc\_fuel/00%20Overview\.md)                  | Fuel level (state bag `ccFuel`) is saved and restored         |
| cc\_lib/00%20Overview\.md)                   | Shared notification and dialog style                          |

{% hint style="info" %}
The script is protected by Cfx asset escrow. `config/`, `locales/` and the framework bridge files in `shared/` remain editable.
{% endhint %}

## Pages

* Installation
* Configuration
* API
* FAQ

Need help? See Support.

## Installation

See also the general installation guide and dependencies.

### Requirements

| Resource                                                                                         | Required    | Purpose                                                                         |
| ------------------------------------------------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------- |
| `oxmysql`                                                                                        | Yes         | Database (declared as `dependency` in the fxmanifest)                           |
| ESX Legacy / QBCore / QBox                                                                       | Yes         | Players, money, jobs, vehicle ownership                                         |
| OneSync                                                                                          | Recommended | Required for persistent vehicles (`Config.Persistent`) and the `Deliver` export |
| `cc_lib`, `cc_keys`, `cc_images`, `cc_fuel`                                                      | Optional    | See overview                                                                    |
| Company account resource (`esx_addonaccount`, `qb-management`, `qbx_management` or `qb-banking`) | Optional    | Tow truck pay with `payFromSociety = true`                                      |

### Steps

1. Copy the folder to `resources/[crankchaos]/cc_garage`.
2. Add to your `server.cfg` (after your framework):

```cfg
ensure oxmysql
ensure cc_lib        # optional
ensure cc_keys       # optional
ensure cc_images     # optional
ensure cc_garage
```

3. Restart the server.

### Database

No SQL file needs to be imported. The table `cc_vehicle_positions` and its columns are created automatically on start. Vehicles are stored in your framework's own vehicle table.

### Framework notes

* The tow truck job uses the job from `Config.Towing.job` (default `mechanic`). This job must exist in your framework.
* On ESX with `Config.Towing.payFromSociety = true` the job needs a society account (`esx_addonaccount`). On QBCore/QBox the company account comes from `qb-management`, `qbx_management` or `qb-banking`.

### Permissions

No ACE permissions are required. The script does not check any ACE rights.

## Configuration

Editable files: `config/config.lua` (gameplay), `config/ui.lua` (look and language), `locales/de.json`, `locales/en.json`, and the framework bridge in `shared/`.

### Interface (`config/ui.lua`)

```lua
Config.Debug = false
Config.UI = {
    theme = 'default',
    primary = '#8B5CF6',
    radius = 'md',
    scale = 1.0,
    locale = 'de',
    animations = true,
    blur = false,
    sounds = true,
}
```

Set `locale = 'en'` for English. `Config.Debug = true` enables the `/ccgarage` test command.

### Interaction

```lua
Config.OpenKey = 38          -- E
Config.Distance = 3.5        -- range to open the garage
Config.ParkDistance = 25.0   -- range to park (checked on the server too)
Config.SpawnClearance = 3.0  -- free space a spot needs to count as free
```

`Config.Peds` (model `s_m_y_valet_01`, scenario, `distance`, `streamDistance`) places a staff ped at each garage. `Config.Marker` draws a ground marker where no ped stands. `Config.Blips` and `Config.BlipDefaults` control map blips.

### Selling and transfer

```lua
Config.SellRatio = 0.5          -- share of the list price when selling
Config.TransferEnabled = true   -- allow giving vehicles to other players
Config.TrackVehicles = true     -- remember last location ("show on map")
```

### Restart behaviour and persistence

```lua
Config.ReturnOnRestart = false

Config.Persistent = {
    enabled = true,
    saveInterval = 60,     -- seconds between position saves
    maxRestore = 300,      -- max vehicles restored on start
    restoreDelay = 50,     -- ms between restored vehicles
    respawnMissing = true, -- respawn vehicles that vanished from the world
    sinkDepth = -2.0,      -- below this z a land vehicle counts as sunk
}
```

* `ReturnOnRestart = true` sends every retrieved vehicle back to its garage on server start.
* `Persistent` lets the server spawn vehicles so they survive disconnects and restarts. Requires OneSync.

### Services

```lua
Config.Services = {
    retrieve = { enabled = true, fee = 10000 },
    repair = {
        enabled = true,
        base = 750, perEnginePercent = 140, perBodyPercent = 60,
        max = 45000, threshold = 2,
    },
}
```

`retrieve` brings a vehicle back to the garage remotely for a fee. `repair` prices are calculated from missing engine and body health, capped at `max`.

### Impound

```lua
Config.Impound = {
    onDestroyed = true,
    engineThreshold = 0,  -- engine % at which a vehicle counts as destroyed
    delay = 15,           -- grace period in seconds
    garage = 'impound',   -- must be a garage with type = 'impound'
}
```

### Tow truck job

```lua
Config.Towing = {
    enabled = true,
    job = 'mechanic',
    minGrade = 0,
    pay = 1500,
    payFromSociety = true,
    payAccount = 'bank',
    delay = 120,     -- seconds before the order appears
    timeout = 900,   -- after this the vehicle goes to the lot by itself
    trucks = {
        towtruck = { rear = true },
        towtruck2 = { rear = true },
        flatbed = { flatbed = true, offset = vector3(0.0, -2.6, 1.05) },
    },
    hookDistance = 10.0,
    dropRadius = 30.0,
    blip = { sprite = 477, colour = 1, scale = 0.85, shortRange = false },
}
```

With `payFromSociety = true` the driver is paid from the company account; if it holds too little, the driver gets what is available. `false` creates the money. `enabled = false` restores direct impounding without a job.

### Trailers

```lua
Config.Trailers = {
    enabled = true,
    spawnGap = 14.0,
    models = {
        phantom = { 'trailers', 'trailers2', 'trailers3', 'trailerlogs', 'tanker', 'docktrailer' },
        packer = { 'tr2', 'tr3', 'tr4', 'trflat' },
        -- phantom2, phantom3, hauler, hauler2 ...
    },
}
```

Key = tractor spawn name, value = allowed trailer spawn names. The server re-checks the selection against this list.

### Images and preview

```lua
Config.Images = {
    enabled = true,
    base = 'https://cfx-nui-cc_images/vehicles',
    extension = 'webp',
}
```

`Config.Preview` defines where and how the 3D preview is filmed (coords, distance, height, fov, anchor, spin).

### Garages

Each entry in `Config.Garages`:

| Field                       | Meaning                                                        |
| --------------------------- | -------------------------------------------------------------- |
| `id`, `label`               | Identifier and display name                                    |
| `type`                      | `public`, `job` (with `job`/`grade`) or `impound` (with `fee`) |
| `coords`, `ped`             | Interaction point and optional ped position (`vector4`)        |
| `spawns`                    | Spots for retrieving; the first free one is used               |
| `classes`                   | Allowed GTA classes; missing = all                             |
| `classSpawns`               | Spots for specific classes (e.g. a helipad)                    |
| `parkDistance`, `clearance` | Per-garage overrides                                           |
| `blip`                      | `true`, `false` or `{ sprite, colour }`                        |

```lua
{
    id = 'impound',
    label = 'Beschlagnahmung',
    type = 'impound',
    fee = 2500,
    coords = vector3(409.0, -1623.0, 29.3),
    spawns = { vector4(400.5, -1630.0, 29.3, 230.0) },
    blip = { sprite = 68, colour = 1 },
}
```

`Config.Classes` defines the filter tabs in the UI (GTA class IDs per tab).

## Exports, Events & Commands

### Server exports

| Export                             | Parameters                                                       | Returns                                                                                          |
| ---------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `Deliver(src, plate, spawn, fee?)` | Player ID, plate, `{ x, y, z, w }` near the player, optional fee | `ok, error, netId`                                                                               |
| `Impound(plate)`                   | Plate                                                            | `true` if the vehicle is player-owned and now (or already) at the impound lot, otherwise `false` |
| `Nearest(coords, class?)`          | `vector3`/table, optional GTA class                              | ID of the nearest public garage or `nil`                                                         |

```lua
local ok, err, netId = exports.cc_garage:Deliver(src, plate, { x = x, y = y, z = z, w = h }, 250)
exports.cc_garage:Impound(plate)
local garageId = exports.cc_garage:Nearest(GetEntityCoords(GetPlayerPed(src)), 13)
```

* `Deliver` brings a parked, owned vehicle (not from the impound) to a point near the player, e.g. for a phone app. Requires OneSync / `Config.Persistent`. The fee is only charged once the vehicle exists. Error codes include `busy`, `unsupported`, `invalid`, `model`, `noMoney`, `internal`.
* `Impound` performs **no** permission check and does not delete the world entity. Both are the caller's responsibility.

There are no client exports.

### Vehicle state bags

| Key         | Content                                                    |
| ----------- | ---------------------------------------------------------- |
| `ccPlate`   | Plate of a vehicle spawned by the garage                   |
| `ccProps`   | Vehicle properties applied by the client on spawn          |
| `ccTrailer` | Net ID of the attached trailer                             |
| `ccFuel`    | Fuel level 0-100 (standard of cc\_fuel/00%20Overview\.md)) |

### Commands

| Command          | Effect                                                       | Permission            |
| ---------------- | ------------------------------------------------------------ | --------------------- |
| `/ccblips`       | Toggle garage blips                                          | Everyone              |
| `/ccgarage [id]` | Open a garage from anywhere, only when `Config.Debug = true` | Everyone (debug only) |

## FAQ & Troubleshooting

**My vehicle is gone after a disconnect or restart.** Enable `Config.Persistent` and make sure OneSync is on. Without it the client spawns the vehicle and it disappears with the client.

**I want all vehicles back in the garage after a restart.** Set `Config.ReturnOnRestart = true`.

**A vehicle does not show up in a garage.** Garages only list and accept the classes in their `classes` field (boats only at `marina`, aircraft only at `hangar`, trucks at `trucks`). Vehicles without a stored class stay visible; the class is added the next time they are parked.

**Tow truck drivers are not paid.** Check that the job from `Config.Towing.job` exists and, with `payFromSociety = true`, that the company account exists and has money. On ESX this needs `esx_addonaccount`. Otherwise set `payFromSociety = false`.

**A wreck was not impounded.** Destruction is only detected while the owner is in or near the vehicle. A vehicle that burns out unobserved is only recovered by `Config.ReturnOnRestart`. Sinking in the Alamo Sea is only detected by the driver's client.

**`Deliver` returns `unsupported`.** It requires OneSync and `Config.Persistent.enabled = true`.

**No vehicle images.** Install cc\_images%20(cc\_images)/00%20Overview\.md) or point `Config.Images.base` to your own resource. Missing images fall back to the class icon.

**Two aircraft spawn inside each other.** Increase the garage's `clearance` and use spots that are far enough apart.

**Known limitations**

* Helicopter rotor and tail boom damage is not saved.
* Boats parked far from the pier leave the driver swimming.

Still stuck? See Support.


---

# 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://ccfivem.gitbook.io/ccfivem-docs/vehicles/garage-cc_garage.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.
