Hello, I created a Remote Event Sanity Checker class. Do you think this is sufficient enough to block exploiters from firing remote events too much?
Features:
- The RESC instance has a field called Calls for all players who fire the event. Indices of the table are players, values are the number of calls in an interval of one second.
- Every call, the RESC instance increments the number of calls by that player in the Calls field.
- Every second after the call, the RESC instance decrements the number of calls the player has sent.
- If the player exceeds the number of calls per second, the method :addCall() returns false.
local Class_RemoteEventSanityChecker = {}
Class_RemoteEventSanityChecker.__index = Class_RemoteEventSanityChecker
function Class_RemoteEventSanityChecker.new(Inst_re,Int_maxCallsPerSecondPerPlayer)
return setmetatable({
RemoteEvent = Inst_re;
MaximumCallsPerSecondPerPlayer = Int_maxCallsPerSecondPerPlayer;
Calls = {};
},Class_RemoteEventSanityChecker)
end
function Class_RemoteEventSanityChecker:addCall(Inst_player)
local Bool_goodCall = true
if self.Calls[Inst_player] then
self.Calls[Inst_player] = self.Calls[Inst_player] + 1
if self.Calls[Inst_player] > self.MaximumCallsPerSecondPerPlayer then
Bool_goodCall = false
end
else
self.Calls[Inst_player] = 1
end
spawn(function()
wait(1)
self.Calls[Inst_player] = self.Calls[Inst_player] - 1
end)
return Bool_goodCall
end
return Class_RemoteEventSanityChecker