Add alerts

In this page you will learn how you can include new alerts, from simple command-based alerts like /911 to complex custom alerts with advanced functionalities.

Default Alert Commands

Go to configs/cl_config.lua and include your new command inside this table.

-- Priority 'low', 'medium' or 'high'
-- Car robbery, shop robbery and bank robbery can be found inside client/api/alert_handlers.lua
CL_CONFIG.AlertCommands = {
    {
        command = '911',
        job = { 'police' },
        code = '10-13',
        default_priority = 'medium',
        enabled = true,
        anonymous = false,
        --timeout = 10, --Optional timeout you can set in seconds
    },
    {
        command = 'anon911',
        job = { 'police' },
        code = '10-13',
        default_priority = 'medium',
        enabled = true,
        anonymous = true,
    },
    {
        command = 'sos',
        code = 'P2',
        job = { 'police', 'ambulance' },
        prepared_args = 'A officer is in need of assistance, please come as fast as possible.',
        default_priority = 'high',
        enabled = true,
        anonymous = true,
        blip_time = 5,
        -- job_restricted = 'police',  or { 'police', 'ambulance' } (optional)
        sos = true,
        blip = { -- Optional parameter to override the default blip
            sprite = 84,
            colour = 3,
            scale = 0.7,
            flashes = true,
            text = '10-13 - Officer in distress',
        }
    },
    {
        command = 'emergency',
        code = 'P2',
        job = { 'police', 'ambulance' },
        default_priority = 'high',
        enabled = true,
        anonymous = false,
    }
}

Alert Command Parameters

  • command: The command that will be used (e.g., '911', 'sos')

  • job: The job(s) that will receive the alert (string or table)

  • code: The alert code displayed in dispatch

  • default_priority: Alert priority ('low', 'medium', or 'high')

  • enabled: Whether the command is enabled

  • anonymous: If the character name should appear or not

  • timeout: Optional timeout in seconds before alert expires

  • prepared_args: Pre-filled message for the alert

  • job_restricted: Optional restriction on who can use the command

  • sos: Mark as an SOS alert for special handling

  • blip_time: Time in seconds until the blip fades

  • blip: Optional blip configuration override

Custom Alerts

For more advanced alerts that require player data, vehicle information, or custom logic, you can create custom alerts using the dispatch API.

Client-Side API

Getting Player Data

To create custom alerts with dynamic information, use the GetPlayerData export to retrieve comprehensive player information:

This export returns different data depending on whether the player is in a vehicle or not.

Player Data (On Foot)

Player Data (In Vehicle)

When the player is in a vehicle, additional vehicle data is included:

Sending Custom Alerts (Client)

Use the rcore_dispatch:server:sendAlert event to send custom alerts from the client:

Server-Side API

Sending Alerts from Server

You can trigger alerts directly from server-side scripts using TriggerEvent:

Getting Player Data from Server

For server-side scripts that need player data, you can use a callback system:

Alert Types for Statistics

The dispatch system tracks different alert types for statistics:

  • alerts - General alerts

  • bank_robbery - Bank robbery incidents

  • shop_robbery - Store robbery incidents

  • car_robbery - Vehicle theft incidents

Complete Example: Car Theft Alert with Screenshot

Here's a comprehensive example that creates a car theft alert with a screenshot using the screenshot-basicarrow-up-right resource. This example is configured to work with a Discord webhook for image hosting:

API Reference

Alert Data Structure

Parameter
Type
Required
Description

code

string

Yes

Alert code (e.g., "10-64", "10-13")

default_priority

string

Yes

Priority level: "low", "medium", "high"

coords

vector3

Yes

Alert coordinates

job

string/table

Yes

Job(s) to receive alert

text

string

Yes

Alert message text

type

string

Yes

Alert type for statistics

blip_time

number

No

Blip fade time in seconds

image

string

No

Image URL

custom_sound

string

No

Custom sound URL

blip

table

No

Custom blip configuration

Blip Configuration

Parameter
Type
Description

scale

number

Blip size scale

text

string

Blip label text

flashes

boolean

Whether blip should flash

radius

number

Radius blip size (0 or nil = normal blip)

Examples of alert types and their implementations can be found in client/api/alert_handlers.lua.

Last updated