> For the complete documentation index, see [llms.txt](https://docs.kojascripts.eu/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kojascripts.eu/free/carmarket/installation.md).

# Installation

Welcome to **Koja-Carmarket**, a player-driven car market with auctions, exchange zones, rentable parking slots and test drives. This guide walks you through the install end-to-end.

## 📋 Requirements

Before installing Koja-Carmarket, make sure the following resources are present **and start before** `koja-carmarket`:

* [**koja-lib**](https://github.com/KOJA/koja-lib) — framework bridge (ESX / QBCore detection, money helpers, callback API)
* [**oxmysql**](https://github.com/overextended/oxmysql) — database driver
* [**ox\_target**](https://github.com/overextended/ox_target) *(optional)* — targeted interactions; falls back to draw-text + key if missing

{% hint style="warning" %}
**Load order matters.** `koja-lib`, `oxmysql` and `ox_lib` must be `ensure`d in your `server.cfg` **before** `koja-carmarket`, or the resource will fail to start.
{% endhint %}

## 🚀 Installation

{% stepper %}
{% step %}

### Drop the resource into `resources`

Place the unpacked `koja-carmarket` folder anywhere inside `resources/` (e.g. `resources/[koja]/koja-carmarket`).

```
resources/
└── [koja]/
    ├── koja-lib/
    └── koja-carmarket/
```

{% endstep %}

{% step %}

### Install dependencies

Follow the install instructions for each:

* [`koja-lib`](https://github.com/KOJA/koja-lib)
* [`oxmysql`](https://github.com/overextended/oxmysql#installation)
* [`ox_target`](https://overextended.dev/ox_target) *(optional)*
  {% endstep %}

{% step %}

### Database setup

#### Option A — Automatic (recommended)

Tables are created automatically on first start. Confirm this in `shared/config.lua`:

{% code title="shared/config.lua" %}

```lua
Config.Database = {
    AutoCreateTable = true,
}
```

{% endcode %}

#### Option B — Manual SQL import

Run [`database.sql`](https://github.com/KOJA/koja-carmarket/blob/main/database.sql) against your database manually and set `AutoCreateTable = false`.

{% hint style="info" %}
Both options produce the **same** schema. See [Database](/free/carmarket/database.md) for the full table reference.
{% endhint %}
{% endstep %}

{% step %}

### Configure `server.cfg` (order matters)

{% code title="server.cfg" %}

```
ensure oxmysql
ensure ox_target      # optional
ensure koja-lib
ensure koja-carmarket
```

{% endcode %}

{% hint style="danger" %}
`koja-lib` **must** start before `koja-carmarket`. If load order is wrong, you'll see `attempt to index a nil value (field 'Server')` at startup.
{% endhint %}
{% endstep %}

{% step %}

### First-run smoke test

1. Start the server.
2. Look for `[koja-carmarket] Table … created.` or `… already exists` lines in the console.
3. Go to one of the default market zones (e.g. **Mark**, coords `-2187, -409, 13`) — there should be an NPC with a `Car Market` interaction.
4. Open the tablet and verify the UI loads in your `Config.Locale`.
   {% endstep %}
   {% endstepper %}
