> For the complete documentation index, see [llms.txt](https://docs.otherplanet.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.otherplanet.dev/scripts/op-mechanic-v2/exports/server-side.md).

# Server Side

List of server side exports/events

{% hint style="warning" %}
Missing an export? Contact us on our [Discord Server](https://discord.gg/otherplanet).
{% endhint %}

***

### GetVehicleMileage

```lua
local data = exports['op-mechanic']:GetVehicleMileage(plate)
-- { plate, mileageKm, odometer, odometerUnit } | nil
```

```lua
local data = exports['op-mechanic']:GetVehicleMileageByNetId(netId)
```

***

### EnsureVehicleMileage

```lua
local data = exports['op-mechanic']:EnsureVehicleMileage(netId, modelName)
```

* `netId`: `number`
* `modelName`: `string?`
* returns: mileage table or `nil`

***

### SendDispatchAlert

Quick dispatch for other resources. **`job` is required** and must match a shop job key.

```lua
exports['op-mechanic']:SendDispatchAlert(
    'Flat tire',
    'Citizen reports a blown tire near Legion Square.',
    'orange', -- orange | red | green
    { x = 215.12, y = -810.45, z = 30.73 },
    'build',  -- optional icon
    'mechanic'
)
```

Returns the created call table, or `nil`.

***

### CreateDispatch

Full payload. Pass `job` or `src` so the call routes to that shop only.

```lua
exports['op-mechanic']:CreateDispatch({
    job = 'mechanic', -- required unless src is set
    -- src = 12,
    header = 'Engine smoke',
    desc = 'Smoke coming from the hood on Del Perro Freeway.',
    color = 'red',
    coords = { x = -1204.55, y = -778.21, z = 17.33 },
    street = 'Del Perro Fwy', -- optional
    icon = 'build',           -- optional
})
```

***

### Mechanic shops

```lua
local shops = exports['op-mechanic']:GetMechanicShops()
local shop = exports['op-mechanic']:GetMechanicShop(id)
local shop = exports['op-mechanic']:GetMechanicShopByJob(jobName)
```

***

#### Duty helpers

```lua
exports['op-mechanic']:SetDuty(src, true)
exports['op-mechanic']:ToggleDuty(src)
local onDuty = exports['op-mechanic']:IsOnDuty(src)
```

***

#### OnPlateChange

Call this after an external plate changer so history / mileage / persistence stay linked.

```lua
exports['op-mechanic']:OnPlateChange(oldPlate, newPlate, props?)
```

***

#### HasAdminPermission

```lua
local allowed = exports['op-mechanic']:HasAdminPermission(src)
```

#### GetInstalledTuningKits

Returns the current tuning-kit map for a **spawned** vehicle (`slot → kitId`), or `nil` if the vehicle is not found.

```lua
local kits = exports['op-mechanic']:GetInstalledTuningKits(plate)
-- or
local kits = exports['op-mechanic']:GetInstalledTuningKits(netId)

-- {
--   engine = 'forged_v8',
--   tires = 'stock',
--   brakes = 'race_ceramic',
--   drivetrain = 'awd',
-- } | nil
```

* `plateOrNetId`: `string` (plate) or `number` / numeric string (`netId`)
* returns: `table | nil`

Use on spawn / garage take-out / ownership change to re-apply external upgrades.

***

#### op-mechanic:server:tuningKitsChanged

Fires **after** a kit is paid and installed — **not** on menu preview.

```lua
AddEventHandler('op-mechanic:server:tuningKitsChanged', function(data)
    -- data.source      = mechanic src (nil for admin / automatic)
    -- data.netId       = number|nil
    -- data.plate       = string
    -- data.model       = string (lowercase spawn name)
    -- data.workOrderId = string|nil
    -- data.changes     = { { slot, kit, previous, action }, ... }
    -- data.installed   = full slot → kit map

    for i = 1, #data.changes do
        local c = data.changes[i]
        if c.action == 'install' then
            -- apply external upgrade for c.slot / c.kit
        elseif c.action == 'remove' then
            -- remove external upgrade for c.slot (was c.previous)
        end
    end
end)
```

Example `changes` rows:

```lua
{ slot = 'engine', kit = 'forged_v8', previous = 'stock', action = 'install' }
{ slot = 'tires',  kit = nil,         previous = 'track_slick', action = 'remove' }
```

**When it fires**

* Instant / admin / automatic tuning → after confirm + props apply
* Work order flow → after the work order is finished

{% hint style="info" %}
Config: `applyHandling = false` on a slot or kit in `config/TuningKitsConfig.lua` - OP still sells/installs/tracks the kit, but skips `mult` / `set` handling (for external physics).
{% endhint %}
