Files
community_bridge/modules/dispatch/fd_dispatch/server/server.lua
T
2026-04-19 17:10:57 +01:00

49 lines
1.6 KiB
Lua

if GetResourceState('fd_dispatch') == 'missing' then return end
if GetResourceState('lb-tablet') == 'started' then return end
Dispatch = Dispatch or {}
---This will get the name of the in use resource.
---@return string
Dispatch.GetResourceName = function()
return 'fd_dispatch'
end
Dispatch.SendAlert = function(data)
local metadata = {}
if data.vehicle then
table.insert(metadata, {
type = 'vehicle',
model = data.vehicle or locale('unknown_vehicle_model'),
plate = data.plate or nil,
color = data.colorHex or nil
})
end
if type(data.job) == "string" then
data.job = {data.job}
end
local coords = data.coords or GetEntityCoords(GetPlayerPed(data.source))
local alertData = {
source = data.source,
title = data.title or "No message provided",
description = data.message or "",
groups = data.jobs or data.job or {"police"},
code = data.code or '10-80',
priority = data.priority or 2,
metadata = metadata,
blip = {
title = data.title or "No message provided",
coords = coords,
radius = data.blip and data.blip.radius or nil,
sprite = data.blip and data.blip.sprite or 161,
color = data.blip and data.blip.color or 1,
scale = data.blip and data.blip.scale or 1.2,
flashes = data.blip.flash or false,
time = data.time or (6 * 60000),
category = data.category or nil,
},
}
exports.fd_dispatch:addAlert(alertData)
end
return Dispatch