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

# Igris Alerts

<figure><img src="https://2862342791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFnkzyjlqOP6UGw1GyN62%2Fuploads%2FfJSA1hBPsjpuwwwB3UYD%2Falerts.png?alt=media&amp;token=c188f077-7bfb-4303-87f3-b2dfd741fef9" alt=""><figcaption></figcaption></figure>

### Overview and requirements

igris-alerts  is a RedM alert system for VORP servers: players call law enforcement or doctors with a command, and gunshots in towns automatically alert on-duty lawmen. Alerts show a notification and a temporary map blip, and every alert can be logged to Discord.

| Requirement                                                                        | Status   | Notes                                                         |
| ---------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------- |
| RedM server (fx\_version cerulean, game rdr3)                                      | Required | Lua 5.4 is enabled in the manifest                            |
| <a href="https://github.com/VORPCORE/vorp-core-lua" target="_blank">vorp\_core</a> | Required | Used for jobs, grades, characters and notifications           |
| brew\_society                                                                      | Optional | Only needed when `Config.UseBrewSocietyDuty = true` (default) |
| Discord webhook URL                                                                | Optional | Only needed for Discord logs                                  |

config.lua is left open (escrow\_ignore), so every setting below can be edited. The rest of the code is protected by Tebex escrow.

### Installation

Installation takes about five minutes: drop the folder in, set your jobs and webhook, and add one `ensure` line after your dependencies.

1. Download the resource from your Tebex / CFX Portal account (Keymaster → Granted Assets).
2. Extract it and place the `igris-alerts` folder in your `resources` directory (for example `resources/[igris]/igris-alerts`).
3. Do not rename the folder: the export is called as `exports['igris-alerts']`.
4. Open `config.lua` and adapt it to your server:
5. Replace the job names in each alert's `jobs` and `jobgrade` with the exact job names used on your server.
6. Paste your Discord webhook URLs in place of `url_webhook`, or set `Enabled = false`.
7. Set `Config.UseBrewSocietyDuty` to `true` (Brew Society) or `false` (no duty system).
8. Add the resource to your `server.cfg` after its dependencies:

```
ensure vorp_core
ensure brew_society   # only if you use Brew Society duty
ensure igris-alerts
```

5. Restart the server (or run `refresh` then `ensure igris-alerts`).
6. Check the server console. You should see `[igris-alerts] Script créé par Igris` and one `Alerte enregistrée : <name>` line per alert.
7. Test in game: take a configured job, go on duty, and have another player run `/alertpolice`.

Players already in game when the resource starts are registered automatically, so a restart does not require anyone to reconnect.

### Brew Society duty integration

With Brew Society enabled, only players who are on duty receive alerts; off-duty lawmen and doctors are skipped.

```lua
Config.UseBrewSocietyDuty = true   -- only on-duty players receive alerts
Config.UseBrewSocietyDuty = false  -- every player with a listed job and grade receives alerts
```

* The script reads duty through the `brew_society` export `GetUserDuty(source)` (with `getUserDuty` as a fallback). No edit to Brew Society is needed.
* The resource must be named exactly `brew_society` and be started before igris-alerts.
* If `UseBrewSocietyDuty = true` but `brew_society` is not started, nobody is considered on duty and every caller gets the "no one on duty" message. Set it to `false` if you do not use Brew Society.
* When nobody is on duty, the caller sees `Config.NoDutyAlertMessage`, or the alert's own `noDutyAlertMessage` if one is set.

### Configuration reference

Everything is in `config.lua`. Two alerts ship by default, `police` (`/alertpolice`) and `medecin` (`/alertmedecin`), and you can add as many as you want by copying a block in `Config.Alerts`.

#### Alert options (Config.Alerts)

| Key                                | Example                                         | What it does                                                    |
| ---------------------------------- | ----------------------------------------------- | --------------------------------------------------------------- |
| name                               | `'police'`                                      | Internal name, also used by `Config.ShotAlert.AlertName`        |
| command                            | `'alertpolice'`                                 | Chat command players type (without the slash)                   |
| message                            | `"Crime signalé!"`                              | Notification text shown to responders                           |
| alerterTitle / alerterNotification | `"Alerte!"`                                     | Title and text of the confirmation shown to the caller          |
| noDutyAlertMessage                 | `"Aucun médecin..."`                            | Optional: message when nobody is on duty for this alert         |
| messageTime                        | `40000`                                         | Notification duration (ms)                                      |
| jobs                               | `{"marshal", "sherifnh"}`                       | Jobs that receive this alert                                    |
| jobgrade                           | `marshal = {0,1,2}`                             | Grades allowed for each job; every job in `jobs` needs an entry |
| icon / texturedict / color         | `"star"`, `"generic_textures"`, `"COLOR_WHITE"` | VORP left-notification style                                    |
| hash                               | `-1282792512`                                   | Blip style hash                                                 |
| radius                             | `40.0`                                          | Blip radius around the caller                                   |
| blipDelay                          | `5000`                                          | Delay before responders are alerted (ms)                        |
| blipTime                           | `60000`                                         | How long the blip stays on the map (ms)                         |

Add a new alert by copying a block, giving it a unique `name` and `command`, and listing its jobs. Example for a ranger alert:

```lua
{
    name = 'ranger',
    command = 'alertranger',
    message = "A ranger is needed!",
    alerterTitle = "Ranger call",
    alerterNotification = "Rangers have been notified!",
    messageTime = 40000,
    jobs = {"ranger"},
    jobgrade = { ranger = {0, 1, 2, 3} },
    icon = "tick", color = "COLOR_WHITE", texturedict = "generic_textures",
    hash = -1282792512, radius = 40.0,
    blipTime = 60000, blipDelay = 5000
},
```

#### Discord webhooks

* `Config.Webhook` logs command alerts: player name, server ID, alert, command, time and coordinates.
* `Config.ShotAlert.Webhook` logs gunshots: player, town, weapon, time and coordinates.
* Set `Url` to your webhook, and adjust `Name`, `Title`, `Footer` and `Color` (decimal color code). Set `Enabled = false` to turn a log off.

#### Gunshot alerts (Config.ShotAlert)

| Key        | Default                               | What it does                                                                                      |
| ---------- | ------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Enabled    | `true`                                | Turns automatic gunshot alerts on or off                                                          |
| AlertName  | `'police'`                            | Which alert's jobs and blip style receive gunshot reports                                         |
| Cooldown   | `30000`                               | Minimum time between two reports from the same shooter (ms)                                       |
| IgnoreJobs | marshal, sherifnh, policelm, policewe | Jobs whose shots never trigger an alert                                                           |
| Towns      | 6 towns, radius 800.0                 | Zones where shots are reported: Valentine, Strawberry, Blackwater, Rhodes, Saint-Denis, Annesburg |
| Weapons    | 23 firearms + molotov                 | Weapons that trigger a report; others are ignored                                                 |

Add a town with `{ name = "Armadillo", coords = vector3(x, y, z), radius = 500.0 }`. If you rename a law job in `jobs`, rename it in `jobgrade` and `IgnoreJobs` too.

### Commands and developer export

| Command              | Who receives it                                 |
| -------------------- | ----------------------------------------------- |
| `/alertpolice`       | marshal, sherifnh, policelm, policewe (on duty) |
| `/alertmedecin`      | medecinnh, medecinwe, medecinlm (on duty)       |
| Any custom `command` | The jobs listed in that alert                   |

Other resources can register and trigger alerts through a server-side export, for example from a store robbery, a bank heist or an NPC witness script.

```lua
-- server side, in another resource
local robberyAlert = exports['igris-alerts']:RegisterAlert({
    name = 'robbery',
    command = nil,               -- no chat command, script-triggered only
    message = "A store is being robbed!",
    alerterTitle = "Alert",
    alerterNotification = "The sheriffs have been notified.",
    messageTime = 40000,
    jobs = {"sherifnh"},
    jobgrade = { sherifnh = {0, 1, 2, 3, 4, 5, 6} },
    icon = "star", color = "COLOR_WHITE", texturedict = "generic_textures",
    hash = -1282792512, radius = 40.0,
    blipTime = 60000, blipDelay = 0
})

-- later, when the robbery starts (src = the player at the location)
robberyAlert:SendAlert(src)
```

Register each custom alert once (for example at resource start), then call `SendAlert` as often as needed. The blip is placed at the position of the player passed as `src`.

### Troubleshooting

| Problem                                                            | Fix                                                                                                                                                                          |
| ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Caller always gets "no one on duty"                                | Check that the responder is on duty in Brew Society, that `brew_society` is started before igris-alerts, or set `Config.UseBrewSocietyDuty = false`                          |
| Console: `Export Brew Society GetUserDuty/getUserDuty introuvable` | Your Brew Society version does not expose the duty export, or the resource is not named `brew_society`                                                                       |
| Console: `Grades manquants pour le métier '...'`                   | A job in `jobs` has no matching entry in `jobgrade`; add it with the same name                                                                                               |
| Responder with the right job receives nothing                      | Job name or grade does not match your server exactly (case-sensitive); check with your VORP job list                                                                         |
| No gunshot alerts                                                  | `ShotAlert.Enabled` is true, the shooter is inside a town radius, uses a weapon from `Weapons`, does not have an `IgnoreJobs` job, and `AlertName` matches an existing alert |
| No Discord logs                                                    | Webhook `Enabled = true` and `Url` is a valid Discord webhook (not `url_webhook`)                                                                                            |
| `No such export RegisterAlert`                                     | The folder was renamed; it must be `igris-alerts`, and the call must be server-side                                                                                          |

Still stuck? Open a ticket on our Discord with your server console log and your `config.lua`.
