Do you think this Remote Event sanity checker is sufficient?

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?

  • 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

	return setmetatable({
		RemoteEvent = Inst_re;
		MaximumCallsPerSecondPerPlayer = Int_maxCallsPerSecondPerPlayer;
		Calls = {};

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
		self.Calls[Inst_player] = 1
		self.Calls[Inst_player] = self.Calls[Inst_player] - 1
	return Bool_goodCall

return Class_RemoteEventSanityChecker

This is very similar to what I have done but tbh I’m not entirely sure if it’s optimal myself.
However, I wrapped the player object and keep track of calls per second there. I do so with only a couple of int variables (as in I don’t have a variable for each remote). Also, I only need a single “while wait(1) do” loop to -1 calls from each of the int values. I also don’t need to worry about memory leakage because my player wrapper is easily destroyed when the player is removed.

My main problem with your method is that self.Calls will just keep growing and growing as players enter and leave the server (which might cause a memory problem), so for each remote event you would have to self.Calls[Inst_player] = nil when they leave the game.
Although I must admit I’m not very well versed in sanity checking so someone else’s input would be nice for you.

1 Like