# dealer setup

## Overview

This guide explains how to set up a new car dealership from scratch.

{% stepper %}
{% step %}

### Add Dealer to Config

Open `shared/config.lua` and add a new dealer entry:

```lua
Config.dealers = {
    ['Your Dealer Name'] = {
        -- Configuration goes here
    },
}
```

{% endstep %}

{% step %}

### Configure Dealer Zone

The dealer zone is the area where DUI showroom becomes active.

```lua
dealerZone = {
    enable = true,
    coords = vec3(0.0, 0.0, 0.0),     -- Center of the zone
    size = vec3(30.0, 40.0, 11.5),     -- Width, Length, Height
    rotation = 0.0,                      -- Rotation in degrees
    debug = true,                        -- Set true to visualize
},
```

Use `debug = true` to see the zone boundaries in-game while configuring.
{% endstep %}

{% step %}

### Configure Map Blip

```lua
blip = {
    enable = true,
    sprite = 227,           -- Blip icon (see GTA V blip list)
    color = 5,              -- Blip color
    scale = 0.8,            -- Size on map
    shortRange = true,      -- Only show when nearby
    name = "Your Dealer"    -- Name on map
},
```

Common blip sprites for dealerships:

* 227 - Car dealership
* 225 - Garage
* 326 - Premium deluxe motorsport
  {% endstep %}

{% step %}

### Configure NUI Catalog (Optional)

The NUI catalog opens via target interaction and displays vehicles with 3D preview.

```lua
createNUI = {
    target = {
        coords = vec3(0.0, 0.0, 0.0),       -- Where player interacts
        size = vec3(1.0, 1.0, 1.0),
        rotation = vec3(0.0, 0.0, 0.0),
        debug = true,
        distance = 2.5,
    },
    camera = {
        coords = vec3(0.0, 0.0, 0.0),       -- Camera position
        rotation = vec3(-30.0, 0.0, 180.0), -- Pitch, Roll, Yaw
        fov = 90.0
    },
    vehicle = {
        coords = vec3(0.0, 0.0, 0.0),       -- Vehicle spawn position
        heading = 0.0,
        RandomTuning = true,
        TestDrive = {
            -- Test drive config
        },
        buyResult = {
            coords = vec3(0.0, 0.0, 0.0),   -- Where purchased car spawns
            heading = 0.0,
        },
    }
},
```

{% endstep %}

{% step %}

### Configure Test Drive

```lua
TestDrive = {
    enable = true,
    coords = vec3(0.0, 0.0, 0.0),       -- Test drive start position
    heading = 160.0,
    duration = 120,                       -- Seconds
    cost = 500,                           -- Price to test drive
    costPerNotReturnVehicle = 1000,       -- Penalty per 10 seconds
    returnvehZone = {
        coords = vec3(0.0, 0.0, 0.0),   -- Return zone center
        size = vec3(5.0, 5.0, 5.0),
        rotation = 0.0,
        debug = true,
    }
},
```

{% endstep %}

{% step %}

### Configure DUI Showroom

#### Option A: Replace Existing Texture

Use this when replacing textures on existing props (like dealership screens).

```lua
showRoom = {
    enable = true,
    dui = {
        type = "replace",
        replace = {
            prop = "int_luxshowroom_screens_banners",
            texture = "luxshowroomscreen2"
        },
        resolution = {
            width = 2440,
            height = 1440
        },
        interactions = {
            {
                target = {
                    coords = vec3(0.0, 0.0, 0.0),
                    size = vec3(1.0, 1.0, 1.0),
                    rotation = vec3(0.0, 0.0, 0.0),
                    debug = true,
                    distance = 2.5,
                },
                camera = {
                    coords = vec3(0.0, 0.0, 0.0),
                    rotation = vec3(0.0, 0.0, 0.0),
                    fov = 20.0
                }
            },
        }
    },
    carSpawn = {
        removeVehTime = 50,
        carOptions = {
            coords = vec3(0.0, 0.0, 0.0),
            heading = 120.0,
            canTuning = true,
            randomTuning = true,
        }
    }
}
```

#### Option B: Spawn TV Prop

Use this to spawn a TV prop with DUI texture.

```lua
showRoom = {
    enable = true,
    dui = {
        type = "prop",
        resolution = {
            width = 2440,
            height = 1440
        },
        objects = {
            {
                prop = "prop_tv_flat_03b",
                coords = vec3(0.0, 0.0, 0.0),
                rotation = vec3(-20.0, 0.0, 120.0),
                replace = {
                    prop = "prop_tv_flat_03b",
                    texture = "script_rt_tvscreen"
                }
            },
        },
        interactions = {
            -- Same as above
        },
    },
    carSpawn = {
        -- Same as above
    }
}
```

{% endstep %}

{% step %}

### Create Vehicle Data

Create a JSON file in `data/dealers/` with the dealer name (lowercase, underscores for spaces):

Example: `your_dealer_name.json`

```json
{
    "categories": [
        {
            "name": "Sports",
            "vehicles": [
                {
                    "name": "Elegy RH8",
                    "spawnName": "elegy2",
                    "price": 95000,
                    "stock": 5,
                    "productionYear": 2020,
                    "maxSpeed": 210,
                    "speed": 8,
                    "acceleration": 8,
                    "handling": 8,
                    "braking": 7
                }
            ]
        }
    ]
}
```

{% endstep %}

{% step %}

### Configure Other Place Showroom (Optional)

Teleport players to a separate location for the showroom:

```lua
carSpawn = {
    otherPlace = {
        exitInteraction = {
            coords = vec3(-1072.8, -62.5, -99.0),
            size = vec3(1.0, 1.0, 1.0),
            rotation = vec3(0.0, 0.0, 0.0),
            debug = false,
            distance = 2.5,
        },
        spawnCoords = vec3(-1072.8, -62.5, -99.0),
    },
    carOptions = {
        coords = vec3(-1071.9, -74.5, -99.0),
        heading = 120.0,
        canTuning = true,
        randomTuning = true,
    }
}
```

{% endstep %}

{% step %}

### Finding Coordinates

Use these commands in-game to find coordinates:

```
/coords - Get current position
/heading - Get current heading
```

Or use external tools like:

* vMenu
* Lambda Menu
* CodeWalker
  {% endstep %}

{% step %}

### Testing Your Setup

* Set all `debug` options to `true`
* Restart the resource: `ensure sl-cardealer`
* Walk around and verify:
  * Zone boundaries are correct
  * Target interactions appear
  * Camera angles look good
  * Vehicles spawn in correct positions
* Test the full flow:
  * Enter dealer zone
  * Interact with catalog
  * Select vehicle
  * Start test drive
  * Return vehicle
* Set `debug` to `false` when done
  {% endstep %}
  {% endstepper %}
