Dispatch Alerts

This page explains how to configure and use the Dispatch Alerts system in your server.

client/open/alerts.lua

The above image is an example of how one dispatch notification is made

local dispatchData = {
    title = "Reckless driving / Shooting",  -- The title of the alert, combining both events
    code = '10-11',  -- Alert code for both events
    description = "Reckless driving and possible shooting incident",  -- Combined description of the event
    location = street,  -- Street name where the event occurred
    type = "Alert",  -- Type of alert (Alert for both events)
    sound = "dispatch",  -- Sound to play for the alert
    x = coords.x,  -- X coordinate of the event
    y = coords.y,  -- Y coordinate of the event
    z = coords.z,  -- Z coordinate of the event
    vehicle = {  -- Vehicle details
        model = vehicleData.name,  -- Vehicle model
        plate = vehicleData.plate,  -- Vehicle plate number
        color = vehicleData.color,  -- Vehicle color
        class = vehicleData.class,  -- Vehicle class
        doors = vehicleData.doors,  -- Vehicle doors status
        heading = vehicleData.heading,  -- Vehicle heading
    },
    weapon = {  -- Weapon details (only if the shooting occurred)
        name = GetWeaponName()  -- Name of the weapon used in the shooting incident
    },
    jobs = {  -- Jobs to notify
        police = true,  -- Notify police
    },
    blip = {  -- Blip details for map location (only for shooting in this case)
        radius = 0,  -- No radius for the blip
        sprite = 110,  -- Blip sprite ID for shooting incident
        color = 1,  -- Blip color (usually red for urgent)
        scale = 1.5,  -- Blip size scale
        length = 2,  -- How long the blip stays visible (in minutes)
    }
}

exports['kartik-mdt']:CustomAlert(data)

Client/open/alerts.lua

function Shooting()
    local coords = GetEntityCoords(cache.ped)
    local streetName, crossingRoad = GetStreetNameAtCoord(coords.x, coords.y, coords.z)
    local street = GetStreetNameFromHashKey(streetName)

    local dispatchData = {
        title = "Shooting",
        message = "Discharge of a firearm",
        code = '10-11',
        location = street,
        type = "Alert",
        sound = "dispatch",
        x = coords.x,
        y = coords.y,
        z = coords.z,
        weapon = {
            name = GetWeaponName()
        },
        jobs = { 
            police = true
        },
        blip = {
            radius = 0,
            sprite = 110,
            color = 1,
            scale = 1.5,
            length = 2, -- time in minutes for how long this will stay
        }
    }

    TriggerServerEvent('kartik-mdt:server:sendDispatchNotification', dispatchData)
end

exports('Shooting', Shooting)

and now lets say u want to implement it inside Drug Selling Script

function TriggerDispatchNotification(){
    exports['kartik-mdt']:Shooting()
}

Last updated