diff --git a/README.md b/README.md index 38b7e820..4ddba56a 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,51 @@ Dispatch notifications are sent containing only the alert name, omitting additio - exports['ps-dispatch']:VehicleTheft(vehicle) - exports['ps-dispatch']:YachtHeist() ``` +# Steps to Create New Alert +Add the following into your `alerts.lua` and change to your liking: +``` +local function TestAlert() + local coords = GetEntityCoords(cache.ped) + local vehicle = GetVehicleData(cache.vehicle) + + local dispatchData = { + message = locale('testalert'), -- add this into your locale + codeName = 'testalert', -- this should be the same as in config.lua + code = '10-35', + icon = 'fas fa-car-burst', + priority = 2, + coords = coords, + street = GetStreetAndZone(coords), + heading = GetPlayerHeading(), + vehicle = vehicle.name, + plate = vehicle.plate, + color = vehicle.color, + class = vehicle.class, + doors = vehicle.doors, + jobs = { 'leo' } + } + + TriggerServerEvent('ps-dispatch:server:notify', dispatchData) +end +exports('TestAlert', TestAlert) +``` +Add codeName in `config.lua` for the particular robbery to display the blip +["testalert"] is the codename you passed with the TriggerServerEvent in step 1 +``` + ['testalert'] = { -- Need to match the codeName in alerts.lua + radius = 0, + sprite = 119, + color = 1, + scale = 1.5, + length = 2, + sound = 'Lose_1st', + sound2 = 'GTAO_FM_Events_Soundset', + offset = false, + flash = false + }, +``` +Information about each parameter is in the `alerts.lua` file. + # FAQ * There are no calls showing on dispatch or mdt list. - Make sure you have a job type specified in your qbcore/shared/jobs.lua like: diff --git a/client/alerts.lua b/client/alerts.lua index 87e874b6..aa5fada6 100644 --- a/client/alerts.lua +++ b/client/alerts.lua @@ -1,3 +1,47 @@ +local function CustomAlert(data) + local coords = data.coords or vec3(0.0, 0.0, 0.0) + if data.job then job = data.job end + local gender = GetPlayerGender() + if not data.gender then gender = nil end + + + local dispatchData = { + message = data.message or "", -- Title of the alert + codeName = data.dispatchCode or "NONE", -- Unique name for each alert + code = data.code or '10-80', -- Code that is displayed before the title + icon = data.icon or 'fas fa-question', -- Icon that is displaed after the title + priority = data.priority or 2, -- Changes color of the alert ( 1 = red, 2 = default ) + coords = coords, -- Coords of the player + gender = gender, -- Gender of the player + street = GetStreetAndZone(coords), -- Street of the player + camId = data.camId or nil, -- Cam ID ( for heists ) + color = data.firstColor or nil, -- Color of the vehicle + callsign = data.callsign or nil, -- Callsigns + name = data.name or nil, -- Name of either officer/ems or a player + vehicle = data.model or nil, -- Vehicle name + plate = data.plate or nil, -- Vehicle plate + alertTime = data.alertTime or nil, -- How long it stays on the screen in seconds + doorCount = data.doorCount or nil, -- How many doors on vehicle + automaticGunfire = data.automaticGunfire or false, -- Automatic Gun or not + alert = { + radius = data.radius or 0, -- Radius around the blip + recipientList = job, -- job + sprite = data.sprite or 1, -- Sprite of the blip + color = data.color or 1, -- Color of the blip + scale = data.scale or 0.5, -- Scale of the blip + length = data.length or 2, -- How long it stays on the map + sound = data.sound or "Lose_1st", -- Alert sound + sound2 = data.sound2 or "GTAO_FM_Events_Soundset", -- Alert sound + offset = data.offset or "false", -- Blip / radius offset + flash = data.flash or "false" -- Blip flash + }, + jobs = { 'leo' }, + } + + TriggerServerEvent('ps-dispatch:server:notify', dispatchData) +end +exports('CustomAlert', CustomAlert) + local function VehicleTheft() local coords = GetEntityCoords(cache.ped) local vehicle = GetVehicleData(cache.vehicle) @@ -524,52 +568,6 @@ local function Explosion() end exports('Explosion', Explosion) -local function CustomAlert(data) - local coords = data.coords or vec3(0.0, 0.0, 0.0) - if data.job then job = data.job end - local gender = GetPlayerGender() - if not data.gender then gender = nil end - - - local dispatchData = { - message = data.message or "", - codeName = data.dispatchCode or "NONE", - code = data.code or '10-80', - icon = 'fas fa-fire', - priority = data.priority or 2, - coords = coords, - gender = gender, - street = GetStreetAndZone(coords), - camId = data.camId or nil, - color = data.firstColor or nil, - callsign = data.callsign or nil, - name = data.name or nil, - vehicle = data.model or nil, - plate = data.plate or nil, - alertTime = data.alertTime or nil, - doorCount = data.doorCount or nil, - automaticGunfire = data.automaticGunfire or false, - alert = { - displayCode = data.dispatchCode or "NONE", - description = data.description or "", - radius = data.radius or 0, - recipientList = job, - sprite = data.sprite or 1, - color = data.color or 1, - scale = data.scale or 0.5, - length = data.length or 2, - sound = data.sound or "Lose_1st", - sound2 = data.sound2 or "GTAO_FM_Events_Soundset", - offset = data.offset or "false", - flash = data.flash or "false" - }, - jobs = { 'leo' }, - } - - TriggerServerEvent('ps-dispatch:server:notify', dispatchData) -end -exports('CustomAlert', CustomAlert) - local function PhoneCall(message, anonymous, job, type) local coords = GetEntityCoords(cache.ped)