> 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/features/test-drives.md).

# Test Drives

Let a buyer try the vehicle before they commit. The car spawns at a fixed safe location, runs for a configurable time, and disappears at the end — teleporting the player back to where they started.

## How a player starts one

{% stepper %}
{% step %}

### Open the listing in the tablet

Go to **Market** → click the vehicle you want to test.
{% endstep %}

{% step %}

### Click "Test drive"

If `Config.TestDrive.Enabled = false` or the auction has ended, the button is hidden.
{% endstep %}

{% step %}

### Pay the fee (if any)

`Config.TestDrive.price` is deducted from the player's bank.

{% hint style="warning" %}
The fee is **non-refundable**, even if the player cancels immediately.
{% endhint %}
{% endstep %}

{% step %}

### Drive

The player is teleported into a fresh copy of the vehicle at `Config.TestDrive.coords`. The timer starts:

* Default `Config.TestDrive.secondslimit` = `20` seconds.
* Press `Config.TestDrive.cancelKey` (default **X**, code `73`) to end early.
  {% endstep %}

{% step %}

### Auto-return

When the timer hits zero (or the player cancels), the test vehicle is deleted and the player is teleported back to their original position.
{% endstep %}
{% endstepper %}

## Per-zone configuration

Override the global test-drive settings for a specific zone by adding `testDrive` to the zone:

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

```lua
{
    id = "zone3",
    -- ... other zone fields ...
    testDrive = {
        coords = vec3(1180, 2640, 37.8),
        heading = 90.0,
        secondslimit = 60,
        price = 1000,
        cancelKey = 73,
    },
},
```

{% endcode %}

## Edge cases

| Situation                           | Behavior                                                                                      |
| ----------------------------------- | --------------------------------------------------------------------------------------------- |
| Player disconnects mid-test         | Vehicle entity is auto-cleaned by FiveM; player is teleported back on reconnect (best effort) |
| Resource is restarted mid-test      | `abortMarketTestDriveOnStop` kicks in: vehicle deleted, player teleported back                |
| Player tries to start a second test | `test_drive_busy` notification, ignored                                                       |
| Auction listing, auction ended      | `test_drive_auction_ended` notification, ignored                                              |
| Vehicle has no resolvable model     | `test_drive_no_model` notification, no spawn                                                  |
