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

# Dealerships

One entry in `Config.Shops` is one dealership. Its cars are not in there, they live in `catalog.lua` under the same id. Everything else is set on the dealership itself, there are no global defaults above it.

### A dealership

| Key           | What it is                                              |
| ------------- | ------------------------------------------------------- |
| `id`          | You name it, has to match the list in `catalog.lua`     |
| `label`       | What the panel and the blip are called                  |
| `categories`  | The `Catalog.Categories` ids it shows, in panel order   |
| `locations`   | One entry per lot                                       |
| `interaction` | `marker` or `target`, see below                         |
| `distance`    | How close you have to stand to press E                  |
| `npc`         | Model and scenario of the seller, only used by `target` |
| `blip`        | Sprite, colour, scale, label, or `false` for no blip    |
| `showroom`    | The camera of this dealership                           |

Optional on top: `payment`, `testdrive = false`, `sell = false`, `sellPercent`, `vehicleType` and `icon`.

### The points of a location

Every point is a `vec4`: x, y, z and the heading.

| Key         | What it is                                                           |
| ----------- | -------------------------------------------------------------------- |
| `coords`    | Where the marker sits or the seller stands, and where the menu opens |
| `showroom`  | Where the selected car is shown. Every location needs one            |
| `camera`    | Overrides the dealership camera at this lot only                     |
| `delivery`  | Where a bought car is put down                                       |
| `testdrive` | Where a test drive starts, falls back to `delivery`                  |
| `sell`      | Drive a car here and press E to sell it, `false` for no sell spot    |
| `spawn`     | Where the player is put down after a sale and after a test drive     |
| `label`     | Own name for this lot                                                |

{% hint style="info" %}
`testdrive` and `sell` exist twice on purpose. On the dealership they switch the feature off, on a location they are the spot it happens at.
{% endhint %}

### How a dealership is opened

Two ways, set per dealership with `interaction`. A dealership uses one or the other, never both, and both sit on the location's `coords`.

* `marker` is the default. A marker floats on the spot and you press E. There is no seller NPC here, and nothing but ox\_lib is needed.
* `target` puts a seller NPC on the spot with an ox\_target option on them, and no marker. Only this mode needs ox\_target, and only this mode reads the `npc` setting. With `npc = false` the option sits on the spot without a person.

The marker itself is one setting for the whole resource, `Config.Marker`. It draws the dealership markers and the sell spots alike, so both read as one thing to a player.

| Key               | What it is                                               |
| ----------------- | -------------------------------------------------------- |
| `type`            | GTA marker type, 20 is a chevron, 27 a ring on the floor |
| `width`, `height` | How wide and how tall it is                              |
| `offset`          | How high above the ground it floats                      |
| `faceCamera`      | Keeps the marker turned towards the player               |
| `distance`        | From how far it is drawn, in metres                      |

{% hint style="info" %}
`Config.Marker.distance` is also what the script costs while a player stands nearby, because a marker is redrawn every frame. Keep it as small as you can still see the marker from.
{% endhint %}

### The showroom camera

The camera belongs to the dealership. Every shop has its own `showroom` table, so changing one never touches another and a shop that sells wide things simply gets wider numbers.

```lua
showroom = {
    distance = 6.8,
    minZoom  = 3.0,
    maxZoom  = 11.0,
    height   = 1.5,
    aimHeight = 0.8,
    angle    = 25.0,
    turnSpeed = 0.45,
    smoothing = 0.12,
    autoTurn = 0.0,
    groundSnap = true,
    zOffset  = 0.0,
},
```

`angle` is how the car stands: 0 points the front straight at the camera, 25 turns it a quarter to the side, 180 shows the rear first. The heading of the `showroom` **point** is the side the camera stands on, and the car is turned to face it, so walking that number around moves the camera to another side of the car.

{% hint style="warning" %}
A bigger `distance` moves the camera backwards, not the car, and indoors that is how you end up looking through a wall. Watch `maxZoom` as well, zooming out is the other way through it. If a single lot is tighter than the rest, give that location its own `camera` table with the same keys.
{% endhint %}

### Boats and aircraft

A boat wants its showroom point and its delivery point on the water, at `z = 0.0` along the coast. The showroom puts the boat on the surface by itself; `water = true` in the dealership's `showroom` table forces that when the water is not detected. An aircraft wants a piece of open tarmac with room around it, and a wider camera.
