Shields server-side net events against trigger injectors by enforcing execution cooldowns per player source.
Lua
-- SERVER-SIDE
local executionCooldowns = {}
local function RegisterRateLimitedEvent(eventName, cooldownMs, callback)
RegisterNetEvent(eventName, function(...)
local src = source
local now = GetGameTimer()
executionCooldowns[eventName] = executionCooldowns[eventName] or {}
local lastRun = executionCooldowns[eventName][src] or 0
if (now - lastRun) < cooldownMs then
DropPlayer(src, string.format("[Anti-Cheat] Trigger rate limit exceeded on: %s", eventName))
return
end
executionCooldowns[eventName][src] = now
callback(src, ...)
end)
end
-- Example Usage:
RegisterRateLimitedEvent('shop:purchaseItem', 1500, function(src, itemId, count)
-- Safe transaction logic here
end)Sign in to like this snippet.
Comments (0)
Sign in to comment.