> Marketplace link < {V.1}
This module can prevent Event
spamming & much more.
- RemoteEvent
- RemoteFunction
- BindableEvent
- Webhook Throttling
- And much more!
Open source, distribution while attaining compensation in any sort of currency is disallowed. (no selling this, credit me if you want to).
NOTE : THIS COMES WITH AN AUTOMATIC INTERNAL CLEANER. REMOVES DATA ON LEAVE AUTOMATICALLY, SAVES SERVER MEMORY.
Ability / Functions avaliable
-
function Module_Queue:set_Event_Limit(Event_Name, number_CooldownInSeconds)
This function must be called if you useModule_Queue:return_DidPlayerExceedLimit()
, it initializes the Event limit.
LIMIT : You may set cooldowns as low as0.001 seconds
so the server saves memory.
EXAMPLE
Module_Queue:set_Event_Limit(RemoteEvent_Test.Name, 1.5)
-
Module_Queue:return_DidPlayerExceedLimit(Player.UserId, Event.Name)
This function checks if the player exceeded the limit. If so,true
elsefalse
.
EXAMPLES
MICROSCOPIC EXAMPLE
local bool_IsTheRequestTooQuick = Module_Queue:return_DidPlayerExceedLimit(Player_Local.UserId, RemoteEvent_Test.Name)
print(bool_IsTheRequestTooQuick)
if bool_IsTheRequestTooQuick == true then return end --Do not go forward in the function! Too quick!
CODE - BLOCK EXAMPLE
--[[ EVENT ]]
RemoteEvent_Test.OnServerEvent:Connect(function(Player_Local)
if Module_Queue:return_DidPlayerExceedLimit(Player_Local.UserId, RemoteEvent_Test.Name) == false then
return --CLOSES FUNCTION IF LIMIT EXCEEDED
end
--Script will continue to run if limit is not exceeded.
end)
-
Module_Queue:enable_Kick_Offender(Event_Name, number_Maximum_Offences)
Optional, this will not run by default. Use if you want to kick the Player if they go past the maximum offenses, use this. Do not use this if you have no cooldown for firing events on the Player’s (local / client) scripts.
EXAMPLE
Module_Queue:enable_Kick_Offender(RemoteEvent_Test.Name, 3) -- THIS IS ENTIRELY OPTIONAL, KICKS PLAYERS THAT GO ABOVE THE COOLDOWN!
! SOURCE CODE !
script that calls Module_Queue Source Code
--[[ EXTERNAL DEPENDENCIES ]]
local Module_Queue = require(script:WaitForChild("Module_Queue"))
local RemoteEvent_Test = game.ReplicatedStorage.Folder_Replicated.RemoteEvent_Request_Wear_Garment
--[[ QUEUE SETTINGS ]]
Module_Queue:set_Event_Limit(RemoteEvent_Test.Name, 1.5)
--Module_Queue:enable_Kick_Offender(RemoteEvent_Test.Name, 3) -- THIS IS ENTIRELY OPTIONAL, KICKS PLAYERS THAT GO ABOVE THE COOLDOWN!
--[[ EVENT ]]
RemoteEvent_Test.OnServerEvent:Connect(function(Player_Local)
if Module_Queue:return_DidPlayerExceedLimit(Player_Local.UserId, RemoteEvent_Test.Name) == false then
return
end --CLOSES FUNCTION IF LIMIT EXCEEDED
--Script will continue to run if limit is not exceeded.
end)
Module_Queue Source Code
local Module_Queue = {}
Module_Queue.table_Limit = {}
Module_Queue.table_Queue = {}
Module_Queue.table_Offender = {}
function Module_Queue:return_DidPlayerExceedLimit(Player_Local_UserId,Event_Name)
if self.table_Queue[Event_Name][Player_Local_UserId] then
if math.floor(os.clock()*1000)/1000 - self.table_Queue[Event_Name][Player_Local_UserId] >= self.table_Limit[Event_Name] then
self.table_Queue[Event_Name][Player_Local_UserId] = math.floor(os.clock()*1000)/1000
return true
else
if self.table_Queue[Event_Name].Kick_Offender ~= false then
if self.table_Offender[Player_Local_UserId] then
self.table_Offender[Player_Local_UserId] += 1
if self.table_Offender[Player_Local_UserId] > self.table_Queue[Event_Name].Kick_Offender then
local bool_Success, string_ErrorMessage = pcall(function()
if game.Players:GetPlayerByUserId(Player_Local_UserId) ~= nil then
game.Players:GetPlayerByUserId(Player_Local_UserId):Kick("You have exceeded the Limit.")
end
end)
if string_ErrorMessage then print(string_ErrorMessage) end
else
end
else
self.table_Offender[Player_Local_UserId] = 0
end
end
return false
end
else
self.table_Queue[Event_Name][Player_Local_UserId] = math.floor(os.clock()*1000)/1000
return true
end
end
function Module_Queue:set_Event_Limit(Event_Name,number_CooldownInSeconds)
self.table_Queue[Event_Name] = {}
self.table_Limit[Event_Name] = number_CooldownInSeconds
self.table_Queue[Event_Name].Kick_Offender = false
end
function Module_Queue:enable_Kick_Offender(Event_Name, number_Maximum_Offences)
self.table_Queue[Event_Name].Kick_Offender = number_Maximum_Offences
end
game.Players.PlayerRemoving:Connect(function(Player_Local)
for Name_RemoteEvent, table_RemoteEvent in pairs(Module_Queue.table_Queue) do
if table_RemoteEvent[Player_Local.UserId] then table_RemoteEvent[Player_Local.UserId] = nil end
end
end)
return Module_Queue
Have a nice day’, feel free to request featues or suggestions.