# nova\_dealership

NOVA Framework vehicle dealership system. Buy, test drive, and rent vehicles at configurable dealership locations.

## Features

* **Buy Vehicles** — Purchase vehicles with cash or bank money
* **Test Drive** — Try vehicles for a limited time before buying
* **Rental System** — Rent vehicles for a configurable number of days
* **Multiple Locations** — Support for multiple dealerships with different vehicle inventories
* **Vehicle Categories** — Organize vehicles by type (sedan, SUV, sports, etc.)
* **Color Selection** — Choose vehicle color at purchase
* **Resale** — Sell back vehicles at a percentage of purchase price

## Configuration

Edit `config.lua`:

```lua
DealerConfig = {
    ResalePercent = 0.6,                -- 60% resale value
    TestDriveTime = 60,                 -- Test drive duration (seconds)
    TestDriveReturnDist = 50.0,         -- Max return distance
    RentalDays = 7,                     -- Default rental period
    DefaultGarage = 'legion',           -- Garage for purchased vehicles

    GeneratePlate = function()
        -- Custom plate generation logic
    end,

    Locations = {
        {
            name = 'pdm',
            label = 'Premium Deluxe Motorsport',
            shopType = 'car',
            blip = { sprite = 326, color = 3, scale = 0.7 },
            ped = { model = '...', coords = vector4(...) },  -- Configure per location
            spawn = vector4(...),
            camera = { coords = vector3(...), target = vector3(...) },
        },
        -- More locations...
    },

    VehicleModels = {
        -- UI display name → GTA spawn name
        ['Adder'] = 'adder',
        ['Sultan'] = 'sultan',
    },

    Colors = {
        { id = 0, label = 'Black' },
        { id = 1, label = 'Graphite' },
        -- More colors...
    },
}
```

### Configuration Options

| Option                | Type   | Description                                      |
| --------------------- | ------ | ------------------------------------------------ |
| `ResalePercent`       | number | Percentage of original price on resale (0.0–1.0) |
| `TestDriveTime`       | number | Test drive duration in seconds                   |
| `TestDriveReturnDist` | number | Max distance to return test drive vehicle        |
| `RentalDays`          | number | Default rental period in days                    |
| `DefaultGarage`       | string | Garage ID where purchased vehicles are stored    |
| `Locations`           | table  | Dealership locations with ped, spawn, camera     |
| `VehicleModels`       | table  | Vehicle display name to spawn model mapping      |

## How It Works

1. Player approaches a dealership NPC
2. NUI opens showing available vehicles with prices
3. Player can browse, test drive, or purchase
4. On purchase, vehicle is registered in `nova_vehicles` table and assigned to `DefaultGarage`
5. Test drives have a timer — vehicle is deleted when time expires or player returns

## Dependencies

* **nova\_core** — Player data, money system
* **nova\_garage** — Vehicle registration and storage
* **oxmysql** — Database operations

## Notes

* Purchased vehicles receive an auto-generated license plate
* Vehicle modifications and color are saved on purchase
* Test drive vehicles cannot be stored in garages
* Rental vehicles expire after the configured number of days
* The NUI displays vehicle previews with a camera system
