> 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)
```
