> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nexdev.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Admin panel

> /dealershipadmin is the server-wide vehicle catalog editor and ownership manager. Run it in chat and the admin panel opens; changes go live to every connected client immediately — no restart.

`/dealershipadmin` is the server-wide vehicle **catalog** editor and ownership manager. Run it in chat and the admin panel opens; changes go live to every connected client immediately — no restart.

## Who can open it

Anyone whose identity matches **any** of:

* The configured ace permission (`Config.AdminPanel.AcePermission`, default `nex_dealerships.admin`)
* `group.admin` or `group.superadmin` (so admins work out of the box)
* `command.dealershipadmin` (ox\_lib's restricted-command flag)

Grant a non-admin like this:

```
add_ace identifier.steam:110000123456789 nex_dealerships.admin allow
```

Or grant a whole group:

```
add_ace group.dealership_admin nex_dealerships.admin allow
add_principal identifier.steam:110000123456789 group.dealership_admin
```

If the command does nothing when you type it, you don't have any of these.

## Catalog tab

The catalog is the global list of vehicles available across every dealership lot. Filter by category, search by name, click a row to edit it.

| Field         | Meaning                                                                                                                                                                                                                                                                                                                                   |
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`       | Spawn name (joaat-able, e.g. `sultan`). **Primary key — cannot be changed once saved.**                                                                                                                                                                                                                                                   |
| `name`        | Display name in the showroom (e.g. `Sultan RS`).                                                                                                                                                                                                                                                                                          |
| `brand`       | Optional manufacturer label.                                                                                                                                                                                                                                                                                                              |
| `price`       | Listed price in dollars. The lot can override this per-dealership via the management dashboard.                                                                                                                                                                                                                                           |
| `category`    | One of `sedans`, `compacts`, `sports`, `super`, `sportsclassics`, `coupes`, `muscle`, `suvs`, `offroad`, `vans`, `commercial`, `industrial`, `motorcycles`, `cycles`, `boats`, `planes`, `helicopters`, `emergency`, `service`, `military`, `utility`, `openwheel`, `trains` — or any custom string you also use in a lot's `Categories`. |
| `dealerships` | Optional whitelist — array of dealership keys that may sell this model. Leave blank for "any lot whose categories match".                                                                                                                                                                                                                 |

Click **Save** and the entry is upserted into `nex_dealership_vehicles` and broadcast to every client. **Delete** soft-deletes (sets `deleted = 1`) so historical sales rows keep their references valid.

## Add vehicle tab

A form for one-off additions. Same fields as Catalog → edit.

## Import tab

Pulls a vehicle list from your framework's bundled vehicle data:

* **QBCore** — reads `QBCore.Shared.Vehicles`
* **Qbox** — reads `exports.qbx_core:GetVehiclesByName()`
* **ESX** — reads from the `vehicles` table

Pick a source (or **Auto** to use the detected framework), preview the merged diff, set the defaults for missing fields (`price`, `category` — see `Config.AdminPanel.Import`), and click **Import**.

The flow is idempotent: re-importing only adds **new** models, never overwrites your edits.

<Info>
  A bulk-seed SQL file lives at `install/existing.sql` (around 864 stock GTA vehicles). If you'd rather seed from there than from the framework, run it once against your DB before opening the admin panel.
</Info>

## Dealerships tab

Per-lot ownership and lifecycle controls.

| Action               | What it does                                                                                                                                                                                                                                                                                        |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Set Owner**        | Assigns a player identifier as the dealership's owner. Their cut of every sale is `Config.Purchase.OwnerSplitPercent`. Owners can run `/dealershipmgmt` regardless of job.                                                                                                                          |
| **Clear Owner**      | Removes the owner. Sale split reverts to the job/society flow.                                                                                                                                                                                                                                      |
| **Manage**           | Opens the management dashboard scoped to just this lot — useful for seeding before a handoff.                                                                                                                                                                                                       |
| **Erase Dealership** | Wipes the lot's `nex_dealership_settings`, hidden models, display vehicles, employees, stock, and orders. The lot definition in `shared/locations.lua` is untouched and re-creates the row on next interaction. Use this when transferring ownership to a new player or to reset a lot to defaults. |

<Warning>
  **Erase Dealership** does not refund pending restock orders or active loans. Cancel those from the management dashboard first if you need to.
</Warning>

## Catalog sync

Every catalog save is broadcast to all online clients via `nex_dealerships:admin:syncCatalog`. The local `Vehicles` table merges the patch — saves go live immediately and other admins' edits appear without a refresh.

On player join, the client fetches the full catalog so late-joiners see your edits without a server restart.
