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

# RADAR

Front and rear speed radar with a plate reader, plate history, speed limits, and BOLO alerts from s\_mdt.

A front and rear speed radar for police vehicles that reads plate, model, colour and speed, keeps a plate history, and flags BOLOs from `s_mdt`.

{% embed url="<https://www.youtube.com/watch?v=VIDEO_ID>" %}

***

## ✅ Requirements

|                  |                                                                     |
| ---------------- | ------------------------------------------------------------------- |
| **Frameworks**   | ESX, QBCore, QBX                                                    |
| **Dependencies** | [ox\_lib](https://github.com/overextended/ox_lib)                   |
| **Optional**     | `s_mdt`, for BOLO alerts, quick BOLOs and opening plates in the MDT |

***

## 📥 Installation

```
ensure ox_lib
ensure s_mdt     # optional
ensure s_radar
```

No SQL and no items. Each officer's layout and speed limits are saved on their own client.

***

## ⚙️ Configuration

Everything is in `config/config.lua`. The options not covered here are explained by their comments in the file.

### Access

```lua
AllowedJobs = {
    ['police'] = true,
    ['sheriff'] = true,
},

AllowedVehicles = {
    ['police'] = true,
    ['policeb'] = true,
},
```

On QBCore and QBX the officer must also be on duty; ESX has no duty, so the job is enough. Vehicles match by spawn name.

The radar opens by itself when an allowed officer sits in an allowed vehicle, and closes when they leave the vehicle, lose the job or go off duty. If the officer closes it with `/radar`, it stays closed until they open it again.

<figure><img src="https://3876653196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwqRMsiuM4yL1gQLB2nlA%2Fuploads%2Fgit-blob-880c0c262820709231a3679f4cde2cd74647e591%2Fradar-speeding.jpg?alt=media" alt="The radar tab locked on a vehicle at 142 km/h over an 80 limit, with the rear reading at 49."><figcaption><p>The radar tab locked on a vehicle at 142 km/h over an 80 limit, with the rear reading at 49.</p></figcaption></figure>

### Units

`SpeedMultiplier` does the conversion and `SpeedUnit` is only the label. Change both:

```lua
Radar = {
    SpeedMultiplier = 2.236936,
    SpeedUnit = 'MPH',
},
```

### Speed limits

Officers set the front and rear limits themselves in the radar settings. A vehicle over the limit turns yellow with a beep, and with `SpeedLimits.AutoLock = true` the radar locks on it and keeps following its speed until the officer unlocks it.

<figure><img src="https://3876653196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwqRMsiuM4yL1gQLB2nlA%2Fuploads%2Fgit-blob-0a54f71d950ead0c890bce692df5184d88db01c9%2Fsettings.jpg?alt=media" alt="The settings tab: radar scale at 1.5x, the front limit on at 80 km/h, the rear limit off."><figcaption><p>The settings tab: radar scale at 1.5x, the front limit on at 80 km/h, the rear limit off.</p></figcaption></figure>

### BOLOs with s\_mdt

With `s_mdt` running, plates with an active BOLO show in red with the BOLO count and play a sound (`Radar.PlayBoloAlert`). Clicking a plate opens it in the MDT vehicle search; clicking the BOLO tag opens its BOLOs. Without `s_mdt` the radar only measures, and those buttons are hidden.

{% hint style="info" %}
The radar checks for `s_mdt` when it opens. If `s_mdt` starts after an officer opened the radar, the BOLO features appear the next time they open it.
{% endhint %}

<figure><img src="https://3876653196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwqRMsiuM4yL1gQLB2nlA%2Fuploads%2Fgit-blob-d098cc5d599509d8421895dcabafd9a04e869c74%2Fhistory.jpg?alt=media" alt="The history tab: plates with direction, top speed, model, colour, street and time, one with two BOLOs."><figcaption><p>The history tab: plates with direction, top speed, model, colour, street and time, one with two BOLOs.</p></figcaption></figure>

The megaphone in the history creates a BOLO for that plate. The server checks `AllowedJobs` and duty, limits the details to 500 characters and allows one BOLO every 5 seconds per officer. The BOLO is created in `s_mdt` under the officer's name and job, and every radar that has the plate on screen or in its history flags it at once. Set `Webhooks.QuickBolo` to log them on Discord.

<figure><img src="https://3876653196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwqRMsiuM4yL1gQLB2nlA%2Fuploads%2Fgit-blob-a022d0db5ba4768912bc7e9c60929f5a4f8a2615%2Fcreate-bolo.jpg?alt=media" alt="The new BOLO form with plate, model and colour from the radar, and the details written."><figcaption><p>The new BOLO form with plate, model and colour from the radar, and the details written.</p></figcaption></figure>

***

## 💬 Commands

| Command          | Default key | Who          | What it does                                                    |
| ---------------- | ----------- | ------------ | --------------------------------------------------------------- |
| `/radar`         |             | Allowed jobs | Open or close the radar                                         |
| `/radarcursor`   | `J`         | Allowed jobs | Mouse over the radar to drag it, click plates and open settings |
| `/radarlock`     | `O`         | Allowed jobs | Lock or unlock the readings                                     |
| `/radar_resetui` |             | Everyone     | Put the radar back in the top left corner at 1.0x               |

Names are in `Commands` and default keys in `Keys`. Players rebind the keys in the FiveM key bindings.

***

## 🔌 Integration

| Function                      | File                      | What it is for                                                                                                                                |
| ----------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `Notify(msg, type, duration)` | `config/cl-functions.lua` | Every notification the radar shows                                                                                                            |
| `OnQuickBolo(source, data)`   | `config/sv-functions.lua` | Runs after a BOLO is created from the radar. `data` has `id`, `plate`, `details`, `author`, `identifier`, `job`. Sends the webhook by default |

Job, duty and player name come from `config/framework/`. A custom framework only needs those two files.
