Anti door spam? (spamming E on doors)

If you keep spamming E on door there is no way they will open.
This can be disrupting and annoying on many servers.

But I’ve noticed some servers disallow that; you can only press E once until the door open, and then again once till the door close again.

Is there a plugin or a lua script for that? I’m no a developer, though I’m really curious about this. Seeing it happen and seeing it being disabled by the server/gamemode.

This is a development section, not a request section.

instead of telling him where to post on the forums, why not help instead?
yes, there is a way to do this. you can use the PlayerUse hook to detect when a player uses something, then check if it’s a door and add a timer. i’m not sure how to tell when the door has finished opening/closing, so you’ll just have to use a short timer.
[lua]
hook.Add( “PlayerUse”, “NoDoorSpam”, function( ply, ent )

if ent:GetClass() == "prop_door_rotating" then

	if !ent.LastDoorUse or CurTime() - ent.LastDoorUse > 2 then

		ent.LastDoorUse = CurTime()
		// don't return true here because it will break other things like DarkRP ownership stuff

	else
		return false
	end

end

end )
[/lua]
if you’re wondering where to put this, just save it as a file called nodoorspam.lua in the lua/autorun/server folder

Thanks! I couldn’t find it anywhere… I was just wondering how it looks in Lua and how it works.

Wasn’t sure if I should post it here or in another section; as this is Lua-development related.
Sorry if it stirred any trouble or annoyance.

That won’t work with every door. There are also entities like “func_door” and “func_door_rotating”.



hook.Add( "PlayerUse", "NoDoorSpam", function( ply, ent )

	if ent:GetClass() == "prop_door_rotating" || ent:GetClass() == "func_door_rotating" || ent:GetClass() == "func_door" then

		if !ent.LastDoorUse or CurTime() - ent.LastDoorUse > 2 then

			ent.LastDoorUse = CurTime()
			// don't return true here because it will break other things like DarkRP ownership stuff

		else
			return false
		end

	end

end )


That should work.