diff --git a/client/alerts.lua b/client/alerts.lua index b394083..5811ca7 100644 --- a/client/alerts.lua +++ b/client/alerts.lua @@ -32,8 +32,8 @@ local function CustomAlert(data) length = data.length or 2, -- How long it stays on the map sound = data.sound or "Lose_1st", -- Alert sound sound2 = data.sound2 or "GTAO_FM_Events_Soundset", -- Alert sound - offset = data.offset or "false", -- Blip / radius offset - flash = data.flash or "false" -- Blip flash + offset = data.offset or false, -- Blip / radius offset + flash = data.flash or false -- Blip flash }, jobs = { 'leo' }, } diff --git a/client/eventhandlers.lua b/client/eventhandlers.lua index 1fc24bc..12f905d 100644 --- a/client/eventhandlers.lua +++ b/client/eventhandlers.lua @@ -1,5 +1,19 @@ local timer = {} +--- Safely checks a boolean export on a started resource. +---@param res string Resource name +---@param exp string Export function name +---@return boolean +local function InMinigame(res, exp) + if GetResourceState(res) ~= "started" then return false end + + local ok, result = pcall(function() + return exports[res] and exports[res][exp] and exports[res][exp]() + end) + + return ok and result == true +end + ---@param name string -- The name of the timer ---@param action function -- The function to execute when the timer is up ---@vararg any -- Arguments to pass to the action function @@ -39,6 +53,7 @@ local function BlacklistedWeapon(ped) end AddEventHandler('CEventGunShot', function(witnesses, ped) + if InMinigame("pug-paintball", "IsInPaintball") or InMinigame("pug-battleroyale", "IsInBattleRoyale") then return end if IsPedCurrentWeaponSilenced(cache.ped) then return end if inNoDispatchZone then return end if BlacklistedWeapon(cache.ped) then return end diff --git a/client/main.lua b/client/main.lua index 1833570..e476235 100644 --- a/client/main.lua +++ b/client/main.lua @@ -277,7 +277,7 @@ RegisterNetEvent('ps-dispatch:client:notify', function(data, source) } }) - addBlip(data, Config.Blips[data.codeName] or data) + addBlip(data, Config.Blips[data.codeName] or data.alert) RespondToDispatch:disable(false) OpenDispatchMenu:disable(true)