Jump to content

[REL] Protection from Trigger DDos


Recommended Posts

This simple code will protect you from attacking a server by TriggerServerEvent. Also you can use onPlayerTriggerEventThreshold but I think if player turns off internet and do actions then after turning it on all packets will be send in the same interval.

Change some settings to your own!

-- client side

local ServerCalls
ServerCalls = {
    interval = 1000,
    maxCallsPerInterval = 20,
    time = 0,
    calls = 0,

    refresh = function(self)
        if self.time < getTickCount() then
            self.time = getTickCount() + self.interval
            self.calls = 0
        end
    end,

    add = function(self)
        self:refresh();
        self.calls = self.calls + 1
    end,
}
ServerCalls.__index = ServerCalls

addDebugHook("preFunction", function()

    ServerCalls:add();

    if ServerCalls.calls >= ServerCalls.maxCallsPerInterval and not ServerCalls.makeLastCall then
        triggerServerEvent("banPlayer", resourceRoot)
        ServerCalls.makeLastCall = true
    end

    return ServerCalls.makeLastCall and "skip" or true
end, {"triggerServerEvent"})

-- basic implenemtation of banPlayer (server side)

addEvent("banPlayer", true)
addEventHandler("banPlayer", resourceRoot, function()
    banPlayer(client, true, false, true, "Korea", "Anty ddos")
end)

 

Edited by Korea
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...