Framework = {} ---@type "esx" | "qb-core" | "qbx" | "standalone" local ServerFramework = "standalone" local USING_UIPACK = GetResourceState("prism_uipack") ~= "missing" if Config.Framework == "qb-core" or (Config.Framework == "auto" and GetResourceState("qb-core") == "started") then ServerFramework = "qb-core" QBCore = exports["qb-core"]:GetCoreObject() Utils.Debug("Using QBCore framework") elseif Config.Framework == "esx" or (Config.Framework == "auto" and GetResourceState("es_extended") == "started") then ServerFramework = "esx" ESX = exports["es_extended"]:getSharedObject() Utils.Debug("Using ESX framework") elseif Config.Framework == "qbx" or (Config.Framework == "auto" and GetResourceState("qbx_core") == "started") then ServerFramework = "qbx" QBX = exports.qbx_core Utils.Debug("Using QBX Framework") else ServerFramework = "standalone" Utils.Debug("Using standalone mode") end local initialState = Config.RadiolistStyle if ServerFramework == "esx" then RegisterNetEvent("esx:playerLoaded", function() Citizen.Wait(0) TriggerEvent("prism_radio:playerLoaded") local job = ESX.GetPlayerData()?.job?.name if not job then return end if Config.RadiolistJobBlacklist[job] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end) RegisterNetEvent("esx:setJob", function(job) if not job or not job.name then return end if not next(Config.RadiolistJobBlacklist) then return end if Config.RadiolistJobBlacklist[job.name] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end) if ESX.IsPlayerLoaded() then Citizen.Wait(0) TriggerEvent("prism_radio:playerLoaded") local job = ESX.GetPlayerData()?.job?.name if not job then return end if Config.RadiolistJobBlacklist[job] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end elseif ServerFramework == "qb-core" then RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Citizen.Wait(0) TriggerEvent("prism_radio:playerLoaded") end) RegisterNetEvent("QBCore:Client:OnJobUpdate", function(job) if not job or not job.name then return end if not next(Config.RadiolistJobBlacklist) then return end if Config.RadiolistJobBlacklist[job.name] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end) local job = QBCore?.Functions?.GetPlayerData()?.job?.name if not job then return end if Config.RadiolistJobBlacklist[job] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end elseif ServerFramework == "qbx" then RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() Citizen.Wait(0) TriggerEvent("prism_radio:playerLoaded") end) RegisterNetEvent("QBCore:Client:OnJobUpdate", function(job) if not job or not job.name then return end if not next(Config.RadiolistJobBlacklist) then return end if Config.RadiolistJobBlacklist[job.name] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end) local job = QBX:GetPlayerData()?.job?.name if not job then return end if Config.RadiolistJobBlacklist[job] then Config.RadiolistStyle = 2 Utils.Debug("Hiding radiolist due to blacklisted job") SendNUIMessage({ action = "radio:changeRadiolistStyle", data = { style = 2 } }) else Config.RadiolistStyle = initialState end end function Framework.notify(message, title, type) if USING_UIPACK then TriggerEvent("prism:notify", { description = message, title = title or "Notification", duration = 3000, type = type }) return end if ServerFramework == "esx" then TriggerEvent("esx:showNotification", message, type, 3000, title) return end TriggerEvent("ox_lib:notify", { description = message, title = title or "Notification", duration = 3000, type = type }) end if not Config.DisconnectOnDeath then return end -- Template for your own death system: --[[ ["resource_name"] = { event = "death:event:name", -- (check docs from your ambulance script) cb = function() -- depending on the ambulance job, you would need to check a few parameters in this function because some have multiple death states -- but regular ambulance scripts should work just like that. DisconnectRadio() end } ]] local AMBULANCE_JOBS = { ["p_ambulancejob"] = { event = "p_ambulancejob/onDeathStateChange", cb = function(deathType, data) Utils.Debug("pScripts onDeath event called!") if not deathType or deathType == "none" then return end DisconnectRadio() CloseRadio() end }, ["wasabi_bridge"] = { event = "wasabi_bridge:onPlayerDeath", cb = function() Utils.Debug("wasabi onDeath event called!") DisconnectRadio() CloseRadio() end }, ["es_extended"] = { -- ESX Core event = "esx:onPlayerDeath", cb = function() Utils.Debug("ESX onDeath event called!") DisconnectRadio() CloseRadio() end }, ["qbx_medical"] = { -- QBX Core event = "qbx_medical:client:onPlayerDied", cb = function() Utils.Debug("qbx onDeath event called!") DisconnectRadio() CloseRadio() end }, ["osp_ambulance"] = { event = "osp_ambulance:OnPlayerDead", cb = function() Utils.Debug("osp onDeath event called!") DisconnectRadio() CloseRadio() end }, ["standalone"] = { event = "gameEventTriggered", cb = function(event, data) if event ~= "CEventNetworkEntityDamage" then return end local playerPed = cache.ped local victim = data[1] if not IsPedAPlayer(victim) then return end local victimDied = data[4] if victimDied and playerPed == victim and (IsPedDeadOrDying(victim, true) or IsPedFatallyInjured(victim)) then Utils.Debug("standalone onDeath event called!") DisconnectRadio() CloseRadio() end end } } local handlerAttached = false for resourceName, data in pairs(AMBULANCE_JOBS) do if resourceName ~= "standalone" and data.cb and data.event and GetResourceState(resourceName) ~= "missing" then RegisterNetEvent(data.event, data.cb) handlerAttached = true break end end -- standalone death system is a fallback if your server has no death system or no death system could be detected. if not handlerAttached then local standalone = AMBULANCE_JOBS["standalone"] RegisterNetEvent(standalone.event, standalone.cb) end