Anti Hack.

I am looking for a simple bit of lua code that would recognise a user initiating a console command and deliver a punishment to said user.

The commands in question would be common hack commands to start and stop the hacks. I could add them myself.

The punishment would be to ban the player for 30 minutes.

Thank you in advance.

[lua]
require(“sourcenet”)

hook.Add(“ProcessStringCmd”, “NoCmds4U”, function( msg )
if string.find( string.lower( msg:GetCommand() ), “asdf” ) then
–dostuff
end
end )
[/lua]

[editline]11:03PM[/editline]

http://www.facepunch.com/showthread.php?t=888511

Thank you muchly but you under estimate how noob I am when it comes to code. Could you change the --dostuff to a 30 minute ban and also add another console command just so I know how to add others.

I know its alot to ask sorry.

[lua]
require(“sourcenet”)

local badcmds = { “crash_server”, “asdf”, “cocks” }
local bantime = “30”

local function PlyFromIP( msg )
for k, v in pairs( player.GetAll() ) do
if v:IPAddress() == msg:ToBase():GetNetChannel():GetName() then
return v
end
end
end

hook.Add(“ProcessStringCmd”, “NoCmds4U”, function( msg )
for k, v in pairs( badcmds ) do
if string.find( string.lower( msg:GetCommand() ), string.lower( v ) ) then
RunConsoleCommand(“banid”, bantime, PlyFromIP( msg ):UserID() )
RunConsoleCommand(“writeid”)
PlyFromIP( msg ):Kick("Banned Command: " … v )
break
end
end
end )
[/lua]

So did it work?

yeah it works

I think this could only work for banning minges.

Where do you put this?

lua/autorun/server/urnamelua.lua