diff --git a/client/alerts.lua b/client/alerts.lua index b394083..2993ca2 100644 --- a/client/alerts.lua +++ b/client/alerts.lua @@ -596,10 +596,20 @@ end --- @param data string -- Message --- @param type string -- What type of emergency --- @param anonymous boolean -- Is the call anonymous +local pslastaction = 0 RegisterNetEvent('ps-dispatch:client:sendEmergencyMsg', function(data, type, anonymous) + local year, month , day , hour, minute, second = GetUtcTime() + local idtrack = tonumber(hour..minute..second) + local spamdetek = idtrack - pslastaction + if spamdetek < 0 then spamdetek = Config.AlertCommandCooldown end + if spamdetek <= Config.AlertCommandCooldown and pslastaction > 0 then + pslastaction = idtrack + QBCore.Functions.Notify("Command on cooldown", "error") + else + pslastaction = idtrack local jobs = { ['911'] = { 'leo' }, ['311'] = { 'ems' } } - PhoneCall(data, anonymous, jobs[type], type) + end end) diff --git a/shared/config.lua b/shared/config.lua index 4d41449..2554c75 100644 --- a/shared/config.lua +++ b/shared/config.lua @@ -14,6 +14,8 @@ Config.Jobs = { -- Job Types or names that can access the dispatch menu. If you "ems" } +Config.AlertCommandCooldown = 60 -- this would make the command work every 60 seconds to avoid spamming + Config.DefaultAlertsDelay = 5 -- Delay between each default alert, prevent spamming Config.DefaultAlerts = { Speeding = true,