Entity lag detector. Stop spam attacks with one simple script.

Don’t use this to try kicking/cleaning people that build laggy contraptions. This isn’t made for that and isn’t reliable enough for that. This is for banning asshole 12-year-olds that spam bridges and drop server fps to areas below 5

This script uses the cleanup library and toolgun/physgun hooks to monitor created entities, such as those from the toolgun or any type of prop spawning so that if the server’s frame time goes above a specified value for a specified number of frames, the player’s entities will be cleaned up and can be optionally kicked and banned.

There are some configurations in the script. I’ll list them.

local Should_ban = true --Should ban?
local Should_kick = true --Should Kick?
local Ban_time = 60 --minutes. 0 for permanent
local Log_refreshtime = 1.5 --How long in seconds of no lag until log resets
local Ticks_of_lag = 5 --How many ticks of lag before the server takes action
local Length_of_lag = .2 --How much time a frame is held to be considered lag. .2 is 5 fps

-Works with any entity that can be undone.
-Works with unfreezing clumps of entities.
-Logs spawning from multiple players during lag so if the lag from one isn’t eliminated, it can punish the other too.
Note Players are only logged when the server isn’t lagging, so spawning something while the server is lagging won’t punish you.
Also Note Every log reset time, the log resets. So if you spawn something and the server lags however long the log delay is later. You won’t be punished.
-Cleans up lag inflictor’s props and optionally bans or kicks them.

Known Working Situations
-I spawned 200 unfrozen wooden chairs in each other and the script worked
-Spammed bridges got detected and cleaned.
-Spamming random citizen ragdolls triggers this too.

Instructions - Put Nolag folder in “garrysmod/garrysmod/addons” and make sure to navigate to the lua file and configure it if you want


This is currently a beta and has been tested a lot, but if there are any problems or bugs, please describe them.

Note* When it says “Cleaned Up Everything”, it means everything that player owns is cleaned, not the whole map.

Could you also check the Should collide option and see if it keeps trying to collide with a prop and if they’re both unfrozen?

So if the server lags, it will delete things with the most collisions? Excluding collisions with worldspawn. Is that what you are wanting?

Or freeze/no-collide the prop for a temp amount of time?

Okay. I’ll make that collision detection optional in a few minutes.

Or hours.

After hours of experimenting, I’ve found that when a bunch of props are clumped up, and lagging like shit. They don’t call the shouldcollide hook. I guess this is because they are already colliding and shouldcollide is only called when they are about to collide. Other than keeping constant track of collisions, which I’m afraid might lag. I’ll try it though.

And I’ve come to the conclusion that this isn’t consistent enough and tends to randomly call shouldcollides with anything near lag spaz and not with itself making it grief-able and unpredictable.

Unless there is a module written for this.

No need for a module.

Didn’t see that one, can OP test if that works?

One of my first anti-crash scripts used that. It didn’t work. It would return false most of the time, and randomly return true, but I’ll try it again since it was a while ago.

If its bugged then post it in the niggles thread.

It works now, but it doesn’t return true if props are just colliding or if the physics object is asleep. I’ll post about it returning false to asleep physobjects in niggles, but I think that is something valve will need to fix.

It doesn’t need to return true if it’s colliding, it means the prop isnt inside another prop, you should also have a hook for the ShouldCollide. Sleeping props aren’t penetrating as well because they’re frozen, lol.

Oh well, I don’t see any need for that now anyways. The script gets the job done well enough.

Posted a video. It should show some capabilities of the script.


Great work to see this done.


never gonna give you up

Here’s a bug:

Turn on banning, then spam, get someone else to spawn props too, but not spam them. If it lags to hell, and the other person spawns the last prop, he gets his arse kicked for something he didn’t do, and spam isn’t removed.

It shouldn’t activate unless it’s lagging enough to make the game nearly impossible to play. If you experience people getting kicked while this isn’t the case, I would suggest increasing Length_of_lag and Ticks_of_lag. I can’t really think of any fix to stop people from building the lag up to this threshold, but if I do I’ll implement it.