> 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/developers.md).

# Developers

CAS RedM Cars for developers. Server and client exports for engine health, fuel, odometer, paint, plates and parts, plus the dealership and garage exports and events.

Other scripts can read and change the cars through exports. Everything that changes a car is a server export: the server shares the result with every player.

## cas-car1910 (server)

Units: engine health from 0 (dead) to 1000 (new); fuel in litres (each car's tank from `GetSpecs`); odometer in kilometres.

| Export                             | Returns     | What it does                                                                                |
| ---------------------------------- | ----------- | ------------------------------------------------------------------------------------------- |
| `GetEngineHealth(vehicle)`         | number      | The engine's health                                                                         |
| `SetEngineHealth(vehicle, health)` | boolean     | Sets it (0 stops the engine)                                                                |
| `RepairEngine(vehicle)`            | boolean     | Sets it to 1000                                                                             |
| `GetFuel(vehicle)`                 | number      | Litres in the tank                                                                          |
| `SetFuel(vehicle, litres)`         | boolean     | Sets the tank (clamped to the tank)                                                         |
| `AddFuel(vehicle, litres)`         | boolean     | Adds fuel (clamped)                                                                         |
| `GetSpecs(model)`                  | table       | `{ fuelCapacity, fuelStart, engineMax }` for a model name or hash, `nil` if not a motor car |
| `GetOdometer(vehicle)`             | number      | Kilometres driven                                                                           |
| `SetOdometer(vehicle, km)`         | boolean     | Sets it                                                                                     |
| `GetPaint(vehicle)`                | string      | The car's paint id                                                                          |
| `SetPaint(vehicle, paint)`         | boolean     | Paints the car (a paint id or index from `GetPaints`)                                       |
| `GetPaints(model)`                 | table       | `{ { id, label, rgb } }`, the factory finish first                                          |
| `GetPlate(vehicle)`                | text, style | The licence plate                                                                           |
| `SetPlate(vehicle, text, style)`   | boolean     | Sets the plate text and style                                                               |
| `GetPlateStyles(model)`            | table       | The plate styles                                                                            |
| `CleanPlate(text)`                 | string      | A plate text cleaned to the allowed characters                                              |
| `SetPartOpen(vehicle, part, open)` | boolean     | Opens or closes a part (`door_lf`, `hood_l`, `trunk`, `top`, ...)                           |
| `MarkOwned(vehicle)`               | boolean     | Marks a car as owned: it keeps its own paint and plate instead of a random look             |

```lua
local veh = GetVehiclePedIsIn(GetPlayerPed(source), false)
if exports['cas-car1910']:GetEngineHealth(veh) < 300 then
    exports['cas-car1910']:SetEngineHealth(veh, 600)
end
exports['cas-car1910']:AddFuel(veh, 10.0)
```

## cas-car1910 (client)

| Export                                         | What it does                                                                      |
| ---------------------------------------------- | --------------------------------------------------------------------------------- |
| `GetHudData(vehicle)`                          | Speed, revs, gear, engine, body and fuel (%), lamps, odometer: what the HUD shows |
| `SetLocalPaint(vehicle, paint)`                | Paints a local (not networked) car, for previews                                  |
| `SetLocalPlate(vehicle, text, style)`          | Plates a local car                                                                |
| `SetLocalOpen(vehicle, part, open)`            | Opens or closes a part of a local car                                             |
| `SetLocalEngine(vehicle, on)`                  | Runs the engine sound of a local car                                              |
| `LocalHorn(vehicle)`                           | Sounds a local car's horn                                                         |
| `GetPaints(model)` / `GetPlateStyles(model)`   | As on the server                                                                  |
| `BlockFootPrompts(ms)` / `BlockCarPrompts(ms)` | Hides the car's own prompts for a moment, so your script's prompt group can show  |

## cas-dealership (server)

| Export                                | What it does                                                   |
| ------------------------------------- | -------------------------------------------------------------- |
| `GetOwnedVehicles(owner)`             | The cars a character owns (VORP charIdentifier, RSG citizenid) |
| `VehicleInfo(model, props, garageId)` | A model's label, class, spawn model, paint and plate style     |
| `GarageCapacity(garageId)`            | How many cars the garage holds                                 |
| `GetStock(dealershipId, model)`       | A model's stock at a dealership                                |

## cas-garage (server)

| Export / event                                                     | What it does                                                |
| ------------------------------------------------------------------ | ----------------------------------------------------------- |
| `IsStored(vehicleId)`                                              | Whether an owned car is in its garage                       |
| `GetOutNetId(vehicleId)`                                           | The network id of an owned car that is out, `nil` otherwise |
| `DeliveryGarage(dealershipId)`                                     | The garage a car bought at that dealership is kept at       |
| `TriggerEvent("cas-garage:vehicleRemoved", vehicleId)`             | Takes an owned car off the road at once (sold, repossessed) |
| `TriggerEvent("cas-garage:plateChanged", vehicleId, plate, style)` | Shows a new plate on the car if it is out                   |

`vehicleId` is the row id in `cas_dealership_vehicles`.

## cas-vehiclehud (client)

| Export        | What it does                                                                                       |
| ------------- | -------------------------------------------------------------------------------------------------- |
| `HideFor(ms)` | Hides the HUD for a moment (call it every frame while your prompt shows in the lower right corner) |

## cas-carrepair

A repair starts when a player uses the item named in `Config.Item` (`repair_kit`). To use another item, change the name there.
