Request tracker [Events]

This script is a request tracker for users that limits the number of requests a player can send within a certain period. This script helps prevent too frequent requests from players, improving the security and stability of the server.

  1. Initializing the tracker: The function RequestTracker.new(cooldown, maxRequests) creates a new tracker with specified values of cooldown time (default 10 seconds) and maximum number of requests (default 3).

  2. Request tracking: The method trackRequest(player) tracks requests from the player.

  • If the player sends a request for the first time, a record is created with the current time and request counter.
  • If requests continue within the cooldown time, the request counter is incremented.
  • If the number of requests exceeds the allowed limit, the cooldown time is doubled, and the player is kicked out with a notification.

A method for checking active players with an exceeded number of requests
function self.getPlayersWithExceededRequests()
    local players = {}
    for player, data in pairs(self.requestCount) do
        if data.count > self.maxRequests then
            table.insert(players, player)
        end
    end
    return players
end

Version: 1.0.0
Link: Request Tracker

2 Likes

but what’s a request

Remote events/functions. To prevent them from spamming

1 Like

but you would put that logic directly into your event handlers.

This is basically a global debounce for all remotes. I don’t see why someone would want that.

some people asked me about this idea, which is why I posted this

So does it have a purpose? Or it’s just an idea you posted.

Also I reread the post and it’s not even a global debounce. It just kicks the player if they send too many requests, with the default being 3 requests every 10 seconds (???).

So if a player in my game swings their tool more than 3 times in 10 seconds, boom they are kicked…

You can set your own values for each event

Yeah I get that I could. I am asking if there is a purpose to the module. Like if there is ever a reason to use it.

I basically posted it at the request of some people

Id like to see what the request was for. As @batteryday said, there’s not a very good reason I can think of why this would be for all remotes versus per remote.

2 Likes

Exactly. Remote logic should be handled on a per remote basis. And if you handle it correctly you don’t need to put any fancy trackers on it that kick players. Nothing will happen if the player spams the remote.

2 Likes

Tell me, what’s the point of this?

Instead of “Request Tracker”, we call this “Rate-Limiting” (hence why people are confused).

If you want to rate-limit multiple remotes, I assume you would create RequestTracker.new multiple times?

1 Like