Police alerts
Adding other types of police alerts
Dispatch system examples
Location: Client/functions_open.lua
------- / Robbery notification
RegisterNetEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress',function(playerCoords,currentStreetName)
local PlayerData = QBCore.Functions.GetPlayerData()
if PlayerData.job.name == "police" then
Notifi({ title = Config.title, text = Text('casinorobbery').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
RemoveBlip(blipcasinorob)
blipcasinorob = AddBlipForCoord(playerCoords)
SetBlipSprite(blipcasinorob , 161)
SetBlipScale(blipcasinorob , 2.0)
SetBlipColour(blipcasinorob, 3)
PulseBlip(blipcasinorob)
Wait(100000)
RemoveBlip(blipcasinorob)
end
end)
function Policenotify()
local playerCoords = GetEntityCoords(PlayerPedId(-1))
local currentStreetName = GetCurrentStreetName()
TriggerServerEvent('estrp-casinoheist:robberyinprogress', playerCoords,currentStreetName)
end
Location: Client/functions_open.lua
------- / Robbery notification
--[[RegisterNetEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress',function(playerCoords,currentStreetName)
local PlayerData = QBCore.Functions.GetPlayerData()
if PlayerData.job.name == "police" then
Notifi({ title = Config.title, text = Text('casinorobbery').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
RemoveBlip(blipcasinorob)
blipcasinorob = AddBlipForCoord(playerCoords)
SetBlipSprite(blipcasinorob , 161)
SetBlipScale(blipcasinorob , 2.0)
SetBlipColour(blipcasinorob, 3)
PulseBlip(blipcasinorob)
Wait(100000)
RemoveBlip(blipcasinorob)
end
end)
]]
function Policenotify()
local playerCoords = GetEntityCoords(PlayerPedId(-1))
local currentStreetName = GetCurrentStreetName()
exports['core_dispatch']:addCall(
"10-10",
"Casino is being robbed: " .. currentStreetName,
{
{icon="fa-ruler", info=""},
},
{
playerCoords.x ,playerCoords.y ,playerCoords.z
},
"police",
3000,
11,
5,
false
)
end
------- / Robbery notification
--[[RegisterNetEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress',function(playerCoords,currentStreetName)
local PlayerData = QBCore.Functions.GetPlayerData()
if PlayerData.job.name == "police" then
Notifi({ title = Config.title, text = Text('casinorobbery').. " " .. currentStreetName, duration = 10000, icon = 'fa-solid fa-laptop-code', color = '#ff0000' })
RemoveBlip(blipcasinorob)
blipcasinorob = AddBlipForCoord(playerCoords)
SetBlipSprite(blipcasinorob , 161)
SetBlipScale(blipcasinorob , 2.0)
SetBlipColour(blipcasinorob, 3)
PulseBlip(blipcasinorob)
Wait(100000)
RemoveBlip(blipcasinorob)
end
end)
]]
function Policenotify()
local data = exports['cd_dispatch']:GetPlayerInfo()
TriggerServerEvent('cd_dispatch:AddNotification', {
job_table = {'police', },
coords = data.coords,
title = '10-15 - Casino Robbery',
message = 'Casino security alarm went off!',
flash = 0,
unique_id = data.unique_id,
sound = 1,
blip = {
sprite = 431,
scale = 1.2,
colour = 3,
flashes = true,
text = '112 - Casino',
time = 5,
radius = 0,
}
})
end
------- / Robbery notification
RegisterNetEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress',function(playerCoords,currentStreetName)
if PlayerJob.name == "police" then
exports['ps-dispatch']:CasinoHeist()
end
end)
function Policenotify()
local playerCoords = GetEntityCoords(PlayerPedId(-1))
local currentStreetName = GetCurrentStreetName()
TriggerServerEvent('estrp-casinoheist:robberyinprogress', playerCoords,currentStreetName)
end
Serverside:
RegisterServerEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress', function(playerCoords,currentStreetName)
TriggerClientEvent('estrp-casinoheist:robberyinprogress', source, playerCoords,currentStreetName)
end)
Then you have to make a new alert in: PS-Dispatch/Client/alerts.lua
local function CasinoHeist()
local coords = GetEntityCoords(cache.ped)
local dispatchData = {
message = locale('casinoheist'),
codeName = 'casinoheist',
code = '10-90',
icon = 'fas fa-truck-field',
priority = 2,
coords = coords,
--gender = GetPlayerGender(),
street = GetStreetAndZone(coords),
alertTime = nil,
jobs = { 'police' }
}
TriggerServerEvent('ps-dispatch:server:notify', dispatchData)
end
exports('CasinoHeist', CasinoHeist)
Then Head to the Ps-Dispatch/locales and choose your locale and add:
"casinoheist": "Casino Heist",
Location: Server/functions_serv_open.lua
RegisterServerEvent('estrp-casinoheist:robberyinprogress')
AddEventHandler('estrp-casinoheist:robberyinprogress', function(playerCoords,currentStreetName)
local data = {displayCode = '10-10', description = 'Casino robbery', isImportant = 1, recipientList = {'police'}, length = '20000', infoM = 'fa-info-circle', info = 'Casino is being robbed'}
local dispatchData = {dispatchData = data, caller = 'Casino security system', coords = GetEntityCoords(GetPlayerPed(source))}
TriggerEvent('wf-alerts:svNotify', dispatchData)
end)
Last updated