Code Monkey home page Code Monkey logo

fivem-ratelimiter's Introduction

Rate Limiter

This script adds a rate limiting functionality to your FiveM server. With this script, you'll be able to track if any of your players made too many requests to your server and put your players into a timeout if they exceed a configurable amount of requests per minute.

⚠️ NOTE: You will need some experience in FiveM development in order to use this script. I am happy to help you with implementing this script into your scripts but please make sure you have somewhat at least a small amount of knowledge.

Usage

Register a new rate limiter

⚠️ NOTE: The argument "name" has to be a string. The second argument "attemptsPerMinute" has to be a integer.

exports["oaky_ratelimiter"]:RegisterRateLimiter(rateLimiterName, attemptsPerMinute)
Exports["oaky_ratelimiter"].RegisterRateLimiter(rateLimiterName, attemptsPerMinute)

Hit the rate limiter

The rate limiter won't work if you don't trigger a hit of the rate limiter. Please add this before each of your action and provide the correct name of your rate limiter.

⚠️ NOTE: The argument "name" and "identifier" must be a string.

exports["oaky_ratelimiter"]:HitRateLimiter(identifier, rateLimiterName)
Exports["oaky_ratelimiter"].HitRateLimiter(identifier, rateLimiterName)

Check if an player is in timeout

The return value of this export will only be True if a player has exceeded (MaxAttempts <= CurrentAttempts) the max allowed attempts which you specified in the RegisterRateLimiter export.

⚠️ NOTE: If you don't want to specify the name of a rate limiter please only provide the first argument. Don't provide null or anything else as the second argument.

local isInTimeout = exports["oaky_ratelimiter"]:IsPlayerInTimeout(identifier, rateLimiterName)
OR
local isInTimeout = exports["oaky_ratelimiter"]:IsPlayerInTimeout(identifier)
bool IsInTimeout = Exports["oaky_ratelimiter"].IsPlayerInTimeout(identifier, rateLimiterName)
OR
bool IsInTimeout = Exports["oaky_ratelimiter"].IsPlayerInTimeout(identifier)

Support

You can always reach out to me if you need help or have any questions. I am always happy to help.

You can also contact me on discord if you want: oakyy

fivem-ratelimiter's People

Contributors

marcomiddeldorff avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.