From c0e5241d4019def9c863a41065715584f40f5241 Mon Sep 17 00:00:00 2001 From: Luke20201 Date: Sun, 28 Sep 2025 17:26:03 +0100 Subject: [PATCH] add fd_dispatch support --- .../dispatch/fd_dispatch/client/client.lua | 41 +++++++++++++++++++ .../dispatch/fd_dispatch/server/server.lua | 11 +++++ 2 files changed, 52 insertions(+) create mode 100644 modules/dispatch/fd_dispatch/client/client.lua create mode 100644 modules/dispatch/fd_dispatch/server/server.lua diff --git a/modules/dispatch/fd_dispatch/client/client.lua b/modules/dispatch/fd_dispatch/client/client.lua new file mode 100644 index 0000000..03ac210 --- /dev/null +++ b/modules/dispatch/fd_dispatch/client/client.lua @@ -0,0 +1,41 @@ +---@diagnostic disable: duplicate-set-field +if GetResourceState('fd_dispatch') == 'missing' then return end +if GetResourceState('lb-tablet') == 'started' then return end +Dispatch = Dispatch or {} + +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 + local alertData = { + title = data.message or "No message provided", + description = data.message or "", + groups = data.jobs or data.job or "police", + location = {coords = data.coords, street = GetStreetNameAtCoord(table.unpack(data.coords))} or {coords = GetEntityCoords(PlayerPedId()), street = GetStreetNameAtCoord(table.unpack(GetEntityCoords(PlayerPedId())))}, + code = data.code or '10-80', + priority = data.priority or 2, + metadata = metadata, + blip = { + radius = data.blipData and data.blipData.radius or 0, + sprite = data.blipData and data.blipData.sprite or 161, + color = data.blipData and data.blipData.color or 84, + scale = data.blipData and data.blipData.scale or 1.0, + time = data.time and (data.time / 1000) or nil, + }, + } + exports["fd_dispatch"]:CustomAlert(alertData) +end + +---This will get the name of the in use resource. +---@return string +Dispatch.GetResourceName = function() + return 'fd_dispatch' +end + +return Dispatch \ No newline at end of file diff --git a/modules/dispatch/fd_dispatch/server/server.lua b/modules/dispatch/fd_dispatch/server/server.lua new file mode 100644 index 0000000..ef9fa8f --- /dev/null +++ b/modules/dispatch/fd_dispatch/server/server.lua @@ -0,0 +1,11 @@ +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 + +return Dispatch \ No newline at end of file