From b829edb8354cd08a6ae5fe97c8d6f981ec4da236 Mon Sep 17 00:00:00 2001 From: MrNewb <47620135+MrNewb@users.noreply.github.com> Date: Wed, 5 Feb 2025 20:43:44 -0500 Subject: [PATCH] dispatches updated --- fxmanifest.lua | 3 - modules/dispatch/_default/client/client.lua | 51 +++++++++++++ modules/dispatch/_default/server/server.lua | 11 +++ modules/dispatch/bub_mdt/client/client.lua | 15 ++++ modules/dispatch/bub_mdt/server/server.lua | 2 + modules/dispatch/cd_dispatch/client.lua | 18 ----- .../dispatch/linden_outlawalert/client.lua | 21 ------ .../linden_outlawalert/client/client.lua | 18 +++++ .../linden_outlawalert/server/server.lua | 2 + modules/dispatch/ps-dispatch/client.lua | 75 ------------------- .../dispatch/ps-dispatch/client/client.lua | 29 +++++++ .../dispatch/ps-dispatch/server/server.lua | 2 + modules/dispatch/qs_dispatch/client.lua | 42 ----------- .../dispatch/qs_dispatch/client/client.lua | 38 ++++++++++ .../dispatch/qs_dispatch/server/server.lua | 2 + modules/dispatch/rcore_dispatch/client.lua | 16 ---- 16 files changed, 170 insertions(+), 175 deletions(-) create mode 100644 modules/dispatch/_default/client/client.lua create mode 100644 modules/dispatch/_default/server/server.lua create mode 100644 modules/dispatch/bub_mdt/client/client.lua create mode 100644 modules/dispatch/bub_mdt/server/server.lua delete mode 100644 modules/dispatch/cd_dispatch/client.lua delete mode 100644 modules/dispatch/linden_outlawalert/client.lua create mode 100644 modules/dispatch/linden_outlawalert/client/client.lua create mode 100644 modules/dispatch/linden_outlawalert/server/server.lua delete mode 100644 modules/dispatch/ps-dispatch/client.lua create mode 100644 modules/dispatch/ps-dispatch/client/client.lua create mode 100644 modules/dispatch/ps-dispatch/server/server.lua delete mode 100644 modules/dispatch/qs_dispatch/client.lua create mode 100644 modules/dispatch/qs_dispatch/client/client.lua create mode 100644 modules/dispatch/qs_dispatch/server/server.lua delete mode 100644 modules/dispatch/rcore_dispatch/client.lua diff --git a/fxmanifest.lua b/fxmanifest.lua index 4adb337..bacad92 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -10,8 +10,6 @@ shared_scripts { '@ox_lib/init.lua', 'lib/init.lua', 'settings/sharedConfig.lua', - 'use/*.lua', - 'modules/utility/shared/*.lua', 'modules/math/*.lua', 'modules/locales/*.lua', } @@ -37,7 +35,6 @@ server_scripts { client_scripts { 'settings/clientConfig.lua', 'modules/locales/shared.lua', - 'modules/utility/client/*.lua', 'modules/framework/**/client.lua', 'modules/inventory/**/client.lua', 'modules/doorlock/**/client.lua', diff --git a/modules/dispatch/_default/client/client.lua b/modules/dispatch/_default/client/client.lua new file mode 100644 index 0000000..ddb3718 --- /dev/null +++ b/modules/dispatch/_default/client/client.lua @@ -0,0 +1,51 @@ +Dispatch = Dispatch or {} + +Dispatch.SendAlert = function(data) + TriggerServerEvent('community_bridge:Server:DispatchAlert', { + sprite = data.blipData.sprite or 161, + color = data.blipData.color or 1, + scale = data.blipData.scale or 0.8, + vehicle = data.vehicle or nil, + plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil, + ped = data.ped or cache.ped, + pedCoords = data.pedCoords or GetEntityCoords(cache.ped), + coords = data.coords or GetEntityCoords(cache.ped), + message = data.message or "An Alert Has Been Made", + code = data.code or '10-80', + icon = data.icon or 'fas fa-question', + jobs = data.jobs or {'police'}, + time = data.time or 100000 + }) +end + +RegisterNetEvent('community_bridge:Client:DispatchAlert', function(alert) + Notify.SendNotify(alert.message, "success", 15000) + local blip = Bridge.Utility.CreateBlip(alert.coords, alert.blipData.sprite, alert.blipData.color, alert.blipData.scale, alert.code, true) + Wait(alert.time) + Bridge.Utility.RemoveBlip(blip) +end) + +--[[ +RegisterCommand('testalert', function(source, args) + print('sending alert') + local ped = cache.ped + local vehicle = cache.vehicle + Dispatch.SendAlert({ + vehicle = vehicle or nil, + plate = vehicle and GetVehicleNumberPlateText(vehicle) or nil, + ped = ped, + pedCoords = ped and GetEntityCoords(ped), + coords = GetEntityCoords(ped), + blipData = { + sprite = 161, + color = 1, + scale = 0.8, + }, + message = "Vehicle is being stolen", + code = '10-80', + icon = 'fas fa-question', + jobs = {'police'}, + alertTime = 10 + }) +end, false) +--]] \ No newline at end of file diff --git a/modules/dispatch/_default/server/server.lua b/modules/dispatch/_default/server/server.lua new file mode 100644 index 0000000..4296918 --- /dev/null +++ b/modules/dispatch/_default/server/server.lua @@ -0,0 +1,11 @@ +Dispatch = Dispatch or {} + +RegisterNetEvent("community_bridge:Server:DispatchAlert", function(data) + local jobs = data.jobs + for _, name in pairs(jobs) do + local activeJobPlayers = Bridge.Framework.GetPlayersByJob(name) + for src, _ in pairs(activeJobPlayers) do + TriggerClientEvent('community_bridge:Client:DispatchAlert', src, data) + end + end +end) \ No newline at end of file diff --git a/modules/dispatch/bub_mdt/client/client.lua b/modules/dispatch/bub_mdt/client/client.lua new file mode 100644 index 0000000..999ff62 --- /dev/null +++ b/modules/dispatch/bub_mdt/client/client.lua @@ -0,0 +1,15 @@ +if GetResourceState('bub-mdt') ~= 'started' then return end +Dispatch = Dispatch or {} + +Dispatch.SendAlert = function(data) + local alertData = { + code = data.code or '10-80', + offense = data.message, + coords = data.coords or GetEntityCoords(cache.ped), + info = { label = data.code or '10-80', icon = data.icon or 'fas fa-question' }, + blip = data.blipData.sprite or 1, + isEmergency = data.priority == 1 and true or false, + blipCoords = data.coords or cache.ped and GetEntityCoords(cache.ped) or { x = 0, y = 0}, + } + exports["bub-mdt"]:CustomAlert(alertData) +end \ No newline at end of file diff --git a/modules/dispatch/bub_mdt/server/server.lua b/modules/dispatch/bub_mdt/server/server.lua new file mode 100644 index 0000000..13c866f --- /dev/null +++ b/modules/dispatch/bub_mdt/server/server.lua @@ -0,0 +1,2 @@ +if GetResourceState('bub-mdt') ~= 'started' then return end +Dispatch = Dispatch or {} \ No newline at end of file diff --git a/modules/dispatch/cd_dispatch/client.lua b/modules/dispatch/cd_dispatch/client.lua deleted file mode 100644 index 4547a3d..0000000 --- a/modules/dispatch/cd_dispatch/client.lua +++ /dev/null @@ -1,18 +0,0 @@ -if GetResourceState('cd_dispatch') ~= 'started' then return end - -Dispatch = {} - -Dispatch.SendAlert = function(data) - local playerData = exports['cd_dispatch']:GetPlayerInfo() - local randomID = Utility.CreateUniqueId(nil, 14, nil) - TriggerServerEvent('cd_dispatch:AddNotification', { - job_table = data.job, - coords = data.coords or playerData.coords, - title = data.code or '10-80', - message = data.message, - flash = 0, - unique_id = randomID, - sound = 1, - blip = { sprite = 431, scale = 1.2, colour = 3, flashes = false, text = data.message, time = 10000, radius = 0, } - }) -end \ No newline at end of file diff --git a/modules/dispatch/linden_outlawalert/client.lua b/modules/dispatch/linden_outlawalert/client.lua deleted file mode 100644 index 4007d99..0000000 --- a/modules/dispatch/linden_outlawalert/client.lua +++ /dev/null @@ -1,21 +0,0 @@ -if GetResourceState('linden_outlawalert') ~= 'started' then return end - -Dispatch = {} - -Dispatch.SendAlert = function(data) - local formattedData = { - displayCode = data.code or '10-80', - description = data.message, - isImportant = data.priority or 0, - recipientList = data.job, - length = '10000', - infoM = data.icon or 'fas fa-question', - info = data.message - } - local dispatchData = { - dispatchData = formattedData, - caller = 'Anonymous', - coords = GetEntityCoords(cache.ped) - } - TriggerServerEvent('wf-alerts:svNotify', dispatchData) -end \ No newline at end of file diff --git a/modules/dispatch/linden_outlawalert/client/client.lua b/modules/dispatch/linden_outlawalert/client/client.lua new file mode 100644 index 0000000..1d19ea2 --- /dev/null +++ b/modules/dispatch/linden_outlawalert/client/client.lua @@ -0,0 +1,18 @@ +if GetResourceState('linden_outlawalert') ~= 'started' then return end +Dispatch = Dispatch or {} + +Dispatch.SendAlert = function(data) + TriggerServerEvent('wf-alerts:svNotify', { + dispatchData = { + displayCode = data.code or '211', + description = data.message or "Alert", + isImportant = 0, + recipientList = data.jobs or {'police'}, + length = (data.alertTime * 1000) or '10000', + infoM = data.icon or 'fas fa-question', + info = data.message or "Alert" + }, + caller = 'Anonymous', + coords = data.coords or GetEntityCoords(cache.ped) + }) +end \ No newline at end of file diff --git a/modules/dispatch/linden_outlawalert/server/server.lua b/modules/dispatch/linden_outlawalert/server/server.lua new file mode 100644 index 0000000..1824ed4 --- /dev/null +++ b/modules/dispatch/linden_outlawalert/server/server.lua @@ -0,0 +1,2 @@ +if GetResourceState('linden_outlawalert') ~= 'started' then return end +Dispatch = Dispatch or {} \ No newline at end of file diff --git a/modules/dispatch/ps-dispatch/client.lua b/modules/dispatch/ps-dispatch/client.lua deleted file mode 100644 index 69dad7a..0000000 --- a/modules/dispatch/ps-dispatch/client.lua +++ /dev/null @@ -1,75 +0,0 @@ -if GetResourceState('ps-dispatch') ~= 'started' then return end - -Dispatch = {} - -Dispatch.SendAlert = function(data) - local customData = { - message = data.message, - code = data.code or '10-80', - icon = data.icon or 'fas fa-question', - priority = data.priority or 2, - coords = data.coords or vec3(0.0, 0.0, 0.0), - gender = data.gender or nil, - 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 = { - radius = data.radius or 0, - recipientList = data.job or { 'leo' }, - 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 = { data.job or 'leo' } - } - exports["ps-dispatch"]:CustomAlert(customData) -end - ---[[ --- tested, it worked -CreateThread(function() - local data = { - message = "Fart", - code = '10-80', - icon = 'fas fa-question', - priority = 2, - coords = vec3(0.0, 0.0, 0.0), - gender = nil, - camId = nil, - color = nil, - callsign = nil, - name = "Test Name", - vehicle = nil, - plate = nil, - alertTime = 30000, - doorCount = nil, - automaticGunfire = false, - alert = { - radius = 0, - recipientList = { 'leo' }, - sprite = 1, - color = 1, - scale = 0.5, - length = 2, - sound = "Lose_1st", - sound2 = "GTAO_FM_Events_Soundset", - offset = false, - flash = false - }, - jobs = { 'leo' } - } - Dispatch.SendAlert(data) - Prints.Debug("Dispatched") -end) ---]] \ No newline at end of file diff --git a/modules/dispatch/ps-dispatch/client/client.lua b/modules/dispatch/ps-dispatch/client/client.lua new file mode 100644 index 0000000..7a27093 --- /dev/null +++ b/modules/dispatch/ps-dispatch/client/client.lua @@ -0,0 +1,29 @@ +if GetResourceState('ps-dispatch') ~= 'started' then return end +Dispatch = Dispatch or {} + +Dispatch.SendAlert = function(data) + local alertData = { + message = data.message, + code = data.code or '10-80', + icon = data.icon or 'fas fa-question', + priority = 2, + coords = data.coords, + vehicle = data.vehicle, + plate = data.plate, + alertTime = (data.time or 10000) / 1000, + alert = { + radius = 0, + recipientList = data.jobs, + sprite = data.blipData.sprite, + color = data.blipData.color, + scale = data.blipData.scale, + length = 2, + sound = "Lose_1st", + sound2 = "GTAO_FM_Events_Soundset", + offset = false, + flash = false + }, + jobs = data.jobs + } + exports["ps-dispatch"]:CustomAlert(alertData) +end \ No newline at end of file diff --git a/modules/dispatch/ps-dispatch/server/server.lua b/modules/dispatch/ps-dispatch/server/server.lua new file mode 100644 index 0000000..b19a475 --- /dev/null +++ b/modules/dispatch/ps-dispatch/server/server.lua @@ -0,0 +1,2 @@ +if GetResourceState('ps-dispatch') ~= 'started' then return end +Dispatch = Dispatch or {} diff --git a/modules/dispatch/qs_dispatch/client.lua b/modules/dispatch/qs_dispatch/client.lua deleted file mode 100644 index e336fd7..0000000 --- a/modules/dispatch/qs_dispatch/client.lua +++ /dev/null @@ -1,42 +0,0 @@ -if GetResourceState('qs-dispatch') ~= 'started' then return end - -Dispatch = {} - -Dispatch.SendAlert = function(data) - local playerData = exports['qs-dispatch']:GetPlayerInfo() - if not playerData then - print("Error getting player data") - return - end - - local customData = { - job = data.job or { 'police', 'sheriff', 'traffic', 'patrol' }, -- Job Names - callLocation = data.coords or vec3(0.0, 0.0, 0.0), - callCode = { - code = data.code or '10-80', - snippet = data.snippet or 'General Alert' - }, - message = data.message or "No message provided.", - flashes = data.flash or false, - image = data.image or nil, - blip = { - sprite = data.sprite or 1, - scale = data.scale or 1.0, - colour = data.color or 1, - flashes = data.flash or false, - text = data.blipText or "Alert", - time = data.length and (data.length * 1000) or 20000 -- Default to 20 seconds - }, - otherData = { - { - text = data.name or 'N/A', - icon = data.icon or 'fas fa-question' - } - } - } - - exports['qs-dispatch']:getSSURL(function(image) - customData.image = image or customData.image - TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', customData) - end) -end \ No newline at end of file diff --git a/modules/dispatch/qs_dispatch/client/client.lua b/modules/dispatch/qs_dispatch/client/client.lua new file mode 100644 index 0000000..3656cc7 --- /dev/null +++ b/modules/dispatch/qs_dispatch/client/client.lua @@ -0,0 +1,38 @@ +if GetResourceState('qs-dispatch') ~= 'started' then return end +Dispatch = Dispatch or {} + +Dispatch.SendAlert = function(data) + local playerData = exports['qs-dispatch']:GetPlayerInfo() + if not playerData then return print("Error getting player data") end + + local customData = { + job = data.jobs or { 'police'}, + callLocation = data.coords or vec3(0.0, 0.0, 0.0), + callCode = { + code = data.code or '10-80', + snippet = data.snippet or 'General Alert' + }, + message = data.message, + flashes = false, + image = nil, + blip = { + sprite = data.blipData.sprite or 1, + scale = data.blipData.scale or 1.0, + colour = data.blipData.color or 1, + flashes = false, + text = data.message or "Alert", + time = data.length and (data.time * 1000) or 20000 + }, + otherData = { + { + text = data.name or 'N/A', + icon = data.icon or 'fas fa-question' + } + } + } + + exports['qs-dispatch']:getSSURL(function(image) + customData.image = image or customData.image + TriggerServerEvent('qs-dispatch:server:CreateDispatchCall', customData) + end) +end \ No newline at end of file diff --git a/modules/dispatch/qs_dispatch/server/server.lua b/modules/dispatch/qs_dispatch/server/server.lua new file mode 100644 index 0000000..238df5e --- /dev/null +++ b/modules/dispatch/qs_dispatch/server/server.lua @@ -0,0 +1,2 @@ +if GetResourceState('qs-dispatch') ~= 'started' then return end +Dispatch = Dispatch or {} \ No newline at end of file diff --git a/modules/dispatch/rcore_dispatch/client.lua b/modules/dispatch/rcore_dispatch/client.lua deleted file mode 100644 index 358c9c0..0000000 --- a/modules/dispatch/rcore_dispatch/client.lua +++ /dev/null @@ -1,16 +0,0 @@ -if GetResourceState('rcore_dispatch') ~= 'started' then return end - -Dispatch = {} - -Dispatch.SendAlert = function(data) - local playerData = exports['rcore_dispatch']:GetPlayerData() - TriggerEvent('rcore_dispatch:server:sendAlert', { - code = data.code or '10-80', - default_priority = 'low', - coords = data.coords or playerData.coords, - job = data.job, - text = data.message or 'No message provided', - type = 'alerts', - blip = { sprite = 54, colour = 3, scale = 0.7, text = data.message or "No Message", flashes = false, radius = 0 } - }) -end \ No newline at end of file