Add alerts

In this page you will learn how you can include new alerts, this alerts can be a simple alert like a /911 or a complex one that includes more functionalities.

Simple Alerts

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


CL_CONFIG.AlertCommands = {
    {
        command = '911',
        job = { 'police' },
        code = '10-13',
        default_priority = 'medium',
        enabled = true,
        anonymous = false,
    },
    {
        command = 'anon911',
        job = { 'police' },
        code = '10-13',
        default_priority = 'medium',
        enabled = true,
        anonymous = true,
    },
    {
        command = 'sos',
        code = 'P2',
        job = { 'police', 'ambulance' },
        default_priority = 'high',
        enabled = true,
        anonymous = false
    },
}

You should include some things:

  • command: The command that will be used.

  • job: the job/s name that will receive the alert.

  • code: the alert code.

  • default_priority: the priority of the alert ('low', 'medium' or 'high')

  • enabled: to make sure the command is enabled.

  • anonymous: if the name of the character will appear or not.

Complex Alerts

Client side

To retrieve data of the player to create custom alerts, we provided a easy to implement export which provides a lot of data about the player:

Data export

    local data = exports['rcore_dispatch']:GetPlayerData()

This export returns this data when the player isn't in a vehicle:

    local data = exports['rcore_dispatch']:GetPlayerData()
    data.street_1 -- e.g. "Marina Drive" (The raw street name)
    data.zone -- e.g. "Sandy Shores" (The zone where the player is located)
    data.street -- e.g. "Marina Drive, Sandy Shores" (The street name combined with the zone where the player is located)
    data.coords -- e.g. "vector3(0,0,0)" (The coords where the player is located)
    data.sex -- e.g. "male" (The player ped sex)
    data.ped -- e.g. "4354" (The ped id)

And this when the player is in a vehicle:

    local data = exports['rcore_dispatch']:GetPlayerData()
    data.street_1 -- e.g. "Marina Drive" (The raw street name)
    data.zone -- e.g. "Sandy Shores" (The zone where the player is located)
    data.street -- e.g. "Marina Drive, Sandy Shores" (The street name combined with the zone where the player is located)
    data.coords -- e.g. "vector3(0,0,0)" (The coords where the player is located)
    data.sex -- e.g. "male" (The player ped sex)
    data.ped -- e.g. "4354" (The ped id)

    data.vehicle_data.speed -- e.g. "54 km/h" (The speed in km/h or miles)
    data.vehicle_data.dispatch_color -- e.g. "/#ff000\" (The color formatted for the dispatch)
    data.vehicle_data.color -- e.g. "#ff000" (The color in HEX value)
    data.vehicle_data.model_form -- e.g. "Zentorno" (The vehicle model formatted)
    data.vehicle_data.vehicle_entity -- e.g. "4866" (The vehicle entity)
    data.vehicle_data.model -- e.g. "-1403128555" (The vehicle model)
    data.vehicle_data.model_string -- e.g. "ZENTORNO" (The raw model string)
    data.vehicle_data.heading -- e.g. "West" (The vehicle heading)
    data.vehicle_data.plate -- e.g. "ABC123" (The vehicle plate)

    -- We also include this other values to ensure compatibility with other scripts
    data.vehicle -- e.g. "4866" (The vehicle entity)
    data.vehicle_label -- e.g. "Zentorno" (The vehicle model formatted)
    data.vehicle_colour = -- e.g. "/#ff000\" (The color formatted for the dispatch)
    data.speed = string.format("%.2f", speed) .. ' km/h' -- e.g. "54 km/h" (The speed in km/h or miles)
    data.heading = heading_text -- e.g. "West" (The vehicle heading)
    data.vehicle_plate = plate -- e.g. "ABC123" (The vehicle plate)

The event

The dispatch uses the event rcore_dispatch:server:sendAlert to trigger an alert. The event has the param data which is a lua table that contains the following:

    local data = {
        code = '10-64', -- string -> The alert code, can be for example '10-64' or a little bit longer sentence like '10-64 - Shop robbery'
        default_priority = 'low', -- 'low' | 'medium' | 'high' -> The alert priority
        coords = vector3(0,0,0), -- vector3 -> The coords of the alert
        job = 'police', -- string | table -> The job, for example 'police' or a table {'police', 'ambulance'}
        text = 'Alert here!', -- string -> The alert text
        type = 'alerts', -- alerts | shop_robbery | car_robbery | bank_robbery -> The alert type to track stats
        blip_time = 5, -- number (optional) -> The time until the blip fades
        image = 'url_to_image.jpg', -- string (optional) -> The url to show an image
        custom_sound = 'url_to_sound.mp3', -- string (optional) -> The url to the sound to play with the alert
        blip = { -- Blip table (optional)
            sprite = 54, -- number -> The blip sprite: Find them here (https://docs.fivem.net/docs/game-references/blips/#blips)
            colour = 3, -- number -> The blip colour: Find them here (https://docs.fivem.net/docs/game-references/blips/#blip-colors)
            scale = 0.7, -- number -> The blip scale
            text = 'Car theft', -- number (optional) -> The blip text
            flashes = false, -- boolean (optional) -> Make the blip flash
            radius = 0, -- number (optional) -> Create a radius blip instead of a normal one
        }
    }
    TriggerServerEvent('rcore_dispatch:server:sendAlert', data)

Server side

This can be also triggered from the server side using TriggerEvent.

function shopRobbery()
    local text = 'Hello, they are robbing a store! Please come as fast as possible.'
    local coords = vector3(0, 0, 0)
    local data = {
        code = '10-64', -- string -> The alert code, can be for example '10-64' or a little bit longer sentence like '10-64 - Shop robbery'
        default_priority = 'low', -- 'low' | 'medium' | 'high' -> The alert priority
        coords = vector3(0,0,0), -- vector3 -> The coords of the alert
        job = 'police', -- string | table -> The job, for example 'police' or a table {'police', 'ambulance'}
        text = 'Alert here!', -- string -> The alert text
        type = 'alerts', -- alerts | shop_robbery | car_robbery | bank_robbery -> The alert type to track stats
        blip_time = 5, -- number (optional) -> The time until the blip fades
        image = 'url_to_image.jpg', -- string (optional) -> The url to show an image
        custom_sound = 'url_to_sound.mp3', -- string (optional) -> The url to the sound to play with the alert
        blip = { -- Blip table (optional)
            sprite = 54, -- number -> The blip sprite: Find them here (https://docs.fivem.net/docs/game-references/blips/#blips)
            colour = 3, -- number -> The blip colour: Find them here (https://docs.fivem.net/docs/game-references/blips/#blip-colors)
            scale = 0.7, -- number -> The blip scale
            text = 'Car theft', -- number (optional) -> The blip text
            flashes = false, -- boolean (optional) -> Make the blip flash
            radius = 0, -- number (optional) -> Create a radius blip instead of a normal one
        }
    }
    TriggerEvent('rcore_dispatch:server:sendAlert', data)
end

Let's create a custom alert!

We will create an alert that will be triggered from the client side. The alert will be creating is a car theft which will include a player screenshot!

Let's start retrieving the player data using this function:

   local player_data = exports['rcore_dispatch']:GetPlayerData()

Now let's build the alert text using this data.

    local text = 'Hello, someone here is stealing a %s painted in %s, the gender of the offender is %s and the vehicle plate is %s. Please come as fast as possible to %s!':format(player_data.vehicle_label, player_data.vehicle_colour, player_data.sex, player_data.vehicle_plate, player_data.street)

After bulding the text that will be sent into the alert, let's build the whole event that will be sent to the server, but we want to include an screenshot, then let's use screenshot-basic to do that. With the data build, let's send the event rcore_dispatch:server:sendAlert to the server.


exports['screenshot-basic']:requestScreenshotUpload(CL_CONFIG.CarRobberyPictureWebhook, "files[]", function(val)
    local image = json.decode(val)
    local data = {
        code = '10-64 - Car theft', -- string -> The alert code, can be for example '10-64' or a little bit longer sentence like '10-64 - Shop robbery'
        default_priority = 'low', -- 'low' | 'medium' | 'high' -> The alert priority
        coords = player_data.coords, -- vector3 -> The coords of the alert
        job = 'police', -- string | table -> The job, for example 'police' or a table {'police', 'ambulance'}
        text = text, -- string -> The alert text
        type = 'car_robbery', -- alerts | shop_robbery | car_robbery | bank_robbery -> The alert type to track stats
        blip_time = 5, -- number (optional) -> The time until the blip fades
        image = image.attachments[1].proxy_url,
        custom_sound = 'url_to_sound.mp3', -- string (optional) -> The url to the sound to play with the alert
        blip = { -- Blip table (optional)
            sprite = 54, -- number -> The blip sprite: Find them here (https://docs.fivem.net/docs/game-references/blips/#blips)
            colour = 3, -- number -> The blip colour: Find them here (https://docs.fivem.net/docs/game-references/blips/#blip-colors)
            scale = 0.7, -- number -> The blip scale
            text = 'Car theft', -- number (optional) -> The blip text
            flashes = false, -- boolean (optional) -> Make the blip flash
            radius = 0, -- number (optional) -> Create a radius blip instead of a normal one
        }
    }
    TriggerServerEvent('rcore_dispatch:server:sendAlert', data)
end)

And this is how you can build custom alerts with rcore_dispatch!

The dispatch provides some types of alerts to track stats for police:

  • alerts

  • bank_robbery

  • shop_robbery

  • car_robbery

Examples of this types are all inside the file specified previously.

Last updated