# Police alerts

{% hint style="info" %}
Adding other types of police alerts
{% endhint %}

## Dispatch system examples

{% tabs %}
{% tab title="Default" %}

#### Location: Client/functions.lua

{% code fullWidth="true" %}

```lua

------- / Robbery notification
RegisterNetEvent('estrp-drugheist:robberyinprogress')
AddEventHandler('estrp-drugheist:robberyinprogress',function(truckPos,currentStreetName)
    if PlayerJob.name == "police" then
        Notifi({ title = Config.title, text = Text('drugheist').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
        RemoveBlip(blipdrugheist)
        blipdrugheist = AddBlipForCoord(truckPos)
        SetBlipSprite(blipdrugheist , 161)
        SetBlipScale(blipdrugheist , 2.0)
        SetBlipColour(blipdrugheist, 3)
        PulseBlip(blipdrugheist)
        Wait(100000)
        RemoveBlip(blipdrugheist)
        
        end
    end)

function Policenotify(truckPos)
        local playerCoords = GetEntityCoords(PlayerPedId(-1))
        local currentStreetName = GetCurrentStreetName()
        TriggerServerEvent('estrp-drugheist:robberyinprogress', truckPos,currentStreetName)
end
```

{% endcode %}
{% endtab %}

{% tab title="Core Dispatch" %}
Location: Client/functions.lua

{% code fullWidth="true" %}

```lua
------- / Robbery notification
--[[RegisterNetEvent('estrp-drugheist:robberyinprogress')
AddEventHandler('estrp-drugheist:robberyinprogress',function(truckPos,currentStreetName)
    if PlayerJob.name == "police" then
        Notifi({ title = Config.title, text = Text('drugheist').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
        RemoveBlip(blipdrugheist)
        blipdrugheist = AddBlipForCoord(truckPos)
        SetBlipSprite(blipdrugheist , 161)
        SetBlipScale(blipdrugheist , 2.0)
        SetBlipColour(blipdrugheist, 3)
        PulseBlip(blipdrugheist)
        Wait(100000)
        RemoveBlip(blipdrugheist)
        
        end
    end)
]]
function Policenotify(truckPos)
    local playerCoords = GetEntityCoords(PlayerPedId(-1))
    local currentStreetName = GetCurrentStreetName()
    exports['core_dispatch']:addCall(
     "10-10", 
        "Drug deal went wrong, shots fired: " .. currentStreetName,
    {
        {icon="fa-ruler", info=""},
    },
    {
        truckPos.x ,truckPos.y ,truckPos.z 
    },
    "police", 
    3000, 
    11, 
    5,
    false
)
end
```

{% endcode %}
{% endtab %}

{% tab title="CD\_Dispatch" %}
Location: Client/functions.lua

{% code fullWidth="true" %}

```lua
------- / Robbery notification
--[[RegisterNetEvent('estrp-carrierheist:robberyinprogress')
AddEventHandler('estrp-carrierheist:robberyinprogress',function(playerCoords,currentStreetName)
    if PlayerJob.name == "police" then
        Notifi({ title = Config.title, text = Text('carrierheist').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
        RemoveBlip(blipcarrierheist)
        blipcarrierheist = AddBlipForCoord(playerCoords)
        SetBlipSprite(blipcarrierheist , 161)
        SetBlipScale(blipcarrierheist , 2.0)
        SetBlipColour(blipcarrierheist, 3)
        PulseBlip(blipcarrierheist)
        Wait(100000)
        RemoveBlip(blipcarrierheist)
        
        end
    end)
]]
function Policenotify(truckPos)
     local data = exports['cd_dispatch']:GetPlayerInfo()
        TriggerServerEvent('cd_dispatch:AddNotification', {
            job_table = {'police', }, 
            coords = truckPos.x ,truckPos.y ,truckPos.z,  -- or if truckpos does not work, then data.coords,
            title = '10-15 - Drug deal went wrong!',
            message = 'Drug deal went wrong, shots fired!', 
            flash = 0,
            unique_id = data.unique_id,
            sound = 1,
            blip = {
                sprite = 431, 
                scale = 1.2, 
                colour = 3,
                flashes = true, 
                text = '112 - Drug deal went wrong',
                time = 5,
                radius = 0,
            }
        })
end
```

{% endcode %}
{% endtab %}
{% endtabs %}
