From 7bb65adc303192311bf2aed6bf9c69fb44e335cb Mon Sep 17 00:00:00 2001 From: Knight Development <61920219+coleminer0112@users.noreply.github.com> Date: Sun, 15 Oct 2023 19:47:32 -0700 Subject: [PATCH] create CheckAdminCooldown & SetAdminCoolDown --- server/admin_server.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/server/admin_server.lua b/server/admin_server.lua index df442b85..e00065a6 100644 --- a/server/admin_server.lua +++ b/server/admin_server.lua @@ -10,6 +10,37 @@ ------------------------------------ ------------------------------------ + +-- Cooldowns for Admin Actions +AdminCooldowns = {} +-- Returns true if allowed, false if cooldown active +function CheckAdminCooldown(src, action) + local numSrc = tonumber(src) + if not numSrc then return true end + if AdminCooldowns[numSrc] then + if AdminCooldowns[numSrc][action] then + TriggerClientEvent("EasyAdmin:showNotification", src, GetLocalisedText("waitbeforeusingagain")) + return false + end + end + return true +end + +function SetAdminCooldown(src, action) + local numSrc = tonumber(src) + local coolTime = GetConvarInt("ea_adminCooldown:"..tostring(action), 0) + if action and numSrc and coolTime > 0 then + action = tostring(action) + AdminCooldowns[src] = AdminCooldowns[src] or {} + AdminCooldowns[src][action] = true + Citizen.SetTimeout(1000*coolTime, function() + if AdminCooldowns[src] then + AdminCooldowns[src][action] = nil + end + end) + end +end + -- Chat Reminder Code function sendRandomReminder() reminderTime = GetConvarInt("ea_chatReminderTime", 0)