> For the complete documentation index, see [llms.txt](https://code-after-sex.gitbook.io/script-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://code-after-sex.gitbook.io/script-documentation/cas-redm-cars/dealership.md).

# Dealership

The CAS RedM Cars dealership. Browse and configure cars, test drive, buy with cash or gold, finance, trade in, reputation, stock and every setting.

`cas-dealership` sells the cars. Three dealerships ship: **Saint Denis Motors**, **Blackwater Motors** and the **Valentine Vehicle Dealer**. Each has its own stock, prices, plate prefix and plate style.

## Buying a car

1. Walk up to the counter (map icon) and hold **E** to browse.
   * The showroom opens with the selected car on the floor and a camera you can turn and zoom.
   * While it is open, you are in a private view: no passing wagons, riders or other players.
2. Pick a car and configure it:
   * paint finish;
   * extras;
   * a name;
   * a licence plate number of your own and a plate style.
3. Open the **Purchase** tab and **Review Purchase**:
   * pay in cash or gold, or finance it;
   * trade in the car you own now, if you want to.
4. The bill of sale shows, the showroom closes by itself and you are seated in your new car at the delivery yard.

The car is yours from then on. The garage keeps track of it (see [Garage](/script-documentation/cas-redm-cars/garage.md)).

{% hint style="info" %}
Every check is made on the server before money moves: the price, your money, the stock, the garage's capacity, and whether the plate number is taken. Two purchases at the same moment are refused.
{% endhint %}

## Test drive

From the showroom, **Test Drive** puts you in the car at the delivery yard:

* it lasts 3 minutes, for a $50 deposit that comes back when you return the car (not when the car comes back damaged);
* hold **R** to return it early;
* driving more than 900 m from the dealership, or staying out of the car for 15 seconds, ends the drive.

## Finance

Cars above $1500 can be financed:

* a down payment of 20% to 60%;
* then 4, 6, 8 or 12 installments, taken automatically every 2 hours (charged while the buyer is online);
* a missed installment is counted, and after 3 missed ones the car is repossessed.

## Trade-in

The car you own now can be traded in toward a new one at 40% of its value.

## Reputation

Every purchase earns reputation at that dealership:

| Tier     | Points |
| -------- | ------ |
| Stranger | 0      |
| Known    | 2000   |
| Regular  | 8000   |
| Trusted  | 20000  |
| Honored  | 50000  |

A car can require a reputation tier, a character level, a job or an ACE permission before it can be bought. Locked cars show why.

## Stock

Each dealership has its own stock per model. Staff set it with `/dealershipstock <dealership> <model> <amount>`. A model with no stock can show a note ("Arrives with the next freight from the East").

## Settings (`cas-dealership/config.lua`)

| Setting                  | Default           | What it does                                                                                                           |
| ------------------------ | ----------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `Config.Framework`       | `"auto"`          | `"vorp"`, `"rsg"` or detected                                                                                          |
| `Config.Locale`          | `"en"`            | The language (see [Localization](/script-documentation/cas-redm-cars/localization.md))                                 |
| `Config.Keys`            | E / R / R         | Browse, collect or store (without the garage script), return a test drive                                              |
| `Config.Blip`            | on                | The map icon at each counter                                                                                           |
| `Config.Payments`        | cash, gold (VORP) | The payment methods per framework                                                                                      |
| `Config.Finance`         | on                | Minimum price, rate, terms, down payment range, interval, repossession                                                 |
| `Config.TradeInRate`     | `0.4`             | Share of a car's value paid on trade-in                                                                                |
| `Config.Plates`          | on, $15           | A custom number at purchase and a later change cost $15 each                                                           |
| `Config.Handover`        | on, 1.5 s         | Close the showroom by itself after a purchase and seat the buyer in the car                                            |
| `Config.TestDrive`       | 180 s, $50        | Length, deposit, maximum distance, time allowed out of the car                                                         |
| `Config.PrivateShowroom` | `true`            | The private view while browsing (routing buckets from `ShowroomBucketBase`, 70000)                                     |
| `Config.Garage`          | `cas-garage`, 3   | The garage script and each garage's capacity                                                                           |
| `Config.Categories`      | 9                 | The showroom's categories                                                                                              |
| `Config.Finishes`        |                   | The default paint finishes                                                                                             |
| `Config.Vehicles`        | 20 cars           | Label, description, class, price, seats, tank, finishes, extras, requirements                                          |
| `Config.Dealerships`     | 3                 | Name, town, price factor, gold rate, plate prefix and style, counter, showroom, delivery yard, test drive start, stock |

### Adding a dealership

1. Stand where the counter prompt should be and run `/dealershipcoords`. It prints the position to the F8 console.
2. Copy an entry of `Config.Dealerships` and set its `id`, `name`, `town`, `prompt`, `preview` (the showroom floor spot), `delivery` and `testDrive.spawn`.
3. Fill its `inventory` with models and stock.

## Staff commands

| Command                                           | What it does                                                                                                                                           |
| ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `/tpdealer [saintdenis / blackwater / valentine]` | Takes you to a dealership's counter                                                                                                                    |
| `/dealershipcoords`                               | Prints your position for the config                                                                                                                    |
| `/dealershipstock <dealership> <model> <amount>`  | Sets the stock of a model                                                                                                                              |
| `/dealershiprefund <vehicle id> [amount]`         | Takes back a car sold by mistake and pays its price (or the amount) back to its owner in cash. The owner must be online. Works from the server console |

See [Commands and Permissions](/script-documentation/cas-redm-cars/commands.md) for who can use them.
