> For the complete documentation index, see [llms.txt](https://sbscripts.gitbook.io/sb-scripts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sbscripts.gitbook.io/sb-scripts/sb-speedtraps/installation.md).

# Installation

### Requirements

* **SB Bridge**, which handles the framework, notifications, text UI, target, inventory, money, the admin check and phone emails
* **oxmysql**

SB Speedtraps is set up in SB Bridge's config, not in this script, so pick the framework, notify, text UI, target and inventory there.

### Steps

1. Drop `sbspeedtraps` into your resources folder.
2. Start it after oxmysql and SB Bridge:

```cfg
ensure oxmysql
ensure sbbridge
ensure sbspeedtraps
```

3. **Map:** `html/map.png` is included and calibrated in `Config.Map`. Positions picked on the map can be a few metres off, so check new traps in game.
4. **Database:** nothing to do. Tables, speed tiers and the preconfigured traps are created on first start (`Config.AutoCreateTables`). If your database user can't create tables, run `sql/sb_speedtraps.sql` yourself.
5. Add the ticket item. See Tickets and Licences.
6. Set `Config.Dispatch.System` and check `dispatch.lua`.

### Tables

| Table                     | What it stores                                                                                                                    |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `sb_speedtraps`           | Trap locations, label, position, heading, one-way, tier, active state and blip                                                    |
| `sb_speedtrap_tiers`      | Speed tiers: speed, blip colour, base fine, per-unit fine and maximum fine                                                        |
| `sb_speedtickets`         | Every ticket, with citizen ID, name, plate, vehicle, speed, limit, fine, trap, street, status (unpaid, overdue or paid) and dates |
| `sb_speedtrap_mail`       | Phone emails waiting for an offline player                                                                                        |
| `sb_speedtickets_revoked` | Citizens whose licence this script revoked, so it only gives back licences it took away                                           |
