We will be using a custom export for this tutorial
We will be going over how to use, create and work with exports. The pages are marked on the side of your screen in-case you already read the rest of the docs and figured it out!
Creating the Export (ps-dispatch/client/cl_events.lua)
This callout of dispatch makes use of vehicle information. Which means that the user needs to be in a vehicle for the callout to happen.
local function methRunReport(vehicle)
local vehdata = vehicleData(vehicle)
local currentPos = GetEntityCoords(PlayerPedId())
local locationInfo = getStreetandZone(currentPos)
local heading = getCardinalDirectionFromHeading()
TriggerServerEvent("dispatch:server:notify", {
dispatchcodename = "methRunReport", -- has to match the codes in sv_dispatchcodes.lua so that it generates the right blip
dispatchCode = "10-77",
firstStreet = locationInfo,
model = vehdata.name,
plate = vehdata.plate,
priority = 2,
firstColor = vehdata.colour, -- vehicle color
heading = heading,
automaticGunfire = false,
origin = {
x = currentPos.x,
y = currentPos.y,
z = currentPos.z
},
dispatchMessage = "Drug Run",
job = { "police" }
})
end exports('methRunReport', methRunReport)
If you don't want or require vehicle information then do the following.
local function methRunReport()
local currentPos = GetEntityCoords(PlayerPedId())
local locationInfo = getStreetandZone(currentPos)
local gender = GetPedGender()
TriggerServerEvent("dispatch:server:notify",{
dispatchcodename = "methRunReport", -- has to match the codes in sv_dispatchcodes.lua so that it generates the right blip
dispatchCode = "10-77",
firstStreet = locationInfo,
gender = gender,
model = nil,
plate = nil,
priority = 2, -- priority
firstColor = nil,
automaticGunfire = false,
origin = {
x = currentPos.x,
y = currentPos.y,
z = currentPos.z
},
dispatchMessage = 'Drug Run', -- message
job = {"police" } -- jobs that will get the alerts
})
end exports('methRunReport', methRunReport)
Creating an event with our export
Use the export that HAS vehicle information
RegisterNetEvent("PS:EXAMPLE:EXPORT:GUIDE:VEHICLE", function()
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, true)
exports['ps-dispatch']:methRunReport(vehicle)
end)
Use the export that does NOT have vehicle information.
RegisterNetEvent("PS:EXAMPLE:EXPORT:GUIDE", function()
local ped = PlayerPedId()
exports['ps-dispatch']:methRunReport()
end)
Basically put you add the export exports['ps-dispatch']:methRunReport() where you would want the police to get a notification of what is happening. You can use ps-dispatch to replace qb-core events for notifying police.