Autoban when entering certain command

Hi, I’m looking for a way to automatically ban somebody for a week (Or any set time) when they enter certain commands into the console in my server. I heard this could be done through LUA but I don’t have a clue about it :S. If anyone could help me out here it would be awesome, I want to use it to stop people using certain clientside things.

Thanks in advance.

P.S If it could be set up to ban the player through ULX so a reason is printed in the logs it would be even better, thanks.

Well if you can catch someone running a command can’t you just stop the command from executing?

Place in init.lua

[lua]function hacks(ply)
RunConsoleCommand(“ulx “…“ban “…ply:Name()…” Reason: Aimbotting”)
end
concommand.Add(”+aimbot”,hacks)[/lua]

Thank you very much!
Would there be a way to choose the time that they are banned for?

Am I right in thinking it would be this?

[lua]function hacks(ply)
RunConsoleCommand("ulx "…“ban “…ply:Name()…“10000 “…” Reason: Aimbotting”)
end
concommand.Add(”+aimbot”,hacks)[/lua]

Tested it out but it doesn’t work :S Any help here would be greatly appreciated.

Clientside:


FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*"}
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = ""}

newEngineConCommand = engineConsoleCommand

function engineConsoleCommand(ply , cmd , args)
	for k , v in pairs(FuckYouList) do
		if cmd = v.cmd and string.find(string.lower(v.args) , string.lower(args[1])) then
			RunConsoleCommand("MingeBanning" , cmd , args)
		else
			newEngineConCommand(ply , cmd , args)
		end
	end
end

Serverside:


FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*" , bantime = "0" }
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = "" , bantime = "13379001"}
function ServerCommand(ply , cmd , args)
	newArgs = ""
	for k , v in pairs(args) do
		newArgs = newArgs.." "..v
	end
	file.Write("BannedMinges/"..ply:SteamID():gsub(":" , "_")..".txt" , os.date.."|"..ply:Nick().." Used command "..cmd.." with args "..newArgs)
	for k , v in pairs(FuckYouList) do
		if cmd == v.cmd then
			ply:Ban(tonumber(v.bantime)  , "Minge")
		else
			ply:Ban(0 , "Minge")
			print("Command missing from the list!!!!")
		end
	end
end
concommand.Add("MingeBanning" , ServerCommand)

Not sure if ulx ban can be called directly from the server… (The player argument is not valid, and therefore will not seem to be an admin)

Useful.

I am absolutely hopeless at this so where would I put these codes?

lua/autorun/server for the first one. Add ‘AddCSLuaFile(“autorun/client/Name of the clientside file.lua”)’ at the top of it.

lua/autorun/client for the second one.

Thanks, i’ll try it out now.

[editline]07:40PM[/editline]

Probably because i’m a complete idiot but I can’t get it working.

Both files are called test.lua

Serverside looks like this:
[lua]AddCSLuaFile(“autorun/client/test.lua”)

FuckYouList = {}
FuckYouList[1] = {cmd = “wire_button_model” , args = “*” , bantime = “0” }
FuckYouList[2] = {cmd = “+aimbot_scan” , args = “” , bantime = “13379001”}
function ServerCommand(ply , cmd , args)
newArgs = “”
for k , v in pairs(args) do
newArgs = newArgs…" “…v
end
file.Write(“BannedMinges/”…ply:SteamID():gsub(”:" , “_”)…".txt" , os.date…"|"…ply:Nick()…" Used command “…cmd…” with args "…newArgs)
for k , v in pairs(FuckYouList) do
if cmd == v.cmd then
ply:Ban(tonumber(v.bantime) , “Minge”)
else
ply:Ban(0 , “Minge”)
print(“Command missing from the list!!!”)
end
end
end
concommand.Add(“MingeBanning” , ServerCommand)[/lua]

Clientside looks like this:

[lua]FuckYouList = {}
FuckYouList[1] = {cmd = “wire_button_model” , args = “*”}
FuckYouList[2] = {cmd = “+aimbot_scan” , args = “”}

newEngineConCommand = engineConsoleCommand

function engineConsoleCommand(ply , cmd , args)
for k , v in pairs(FuckYouList) do
if cmd = v.cmd and string.find(string.lower(v.args) , string.lower(args[1])) then
RunConsoleCommand(“MingeBanning” , cmd , args)
else
newEngineConCommand(ply , cmd , args)
end
end
end[/lua]

No files are downloaded when I joined the server and the commands are still usable (I tried +aimbot_scan)

So yea, please let me know what i’m doing wrong.
(Both files are to be placed on the server right? Not meant to have them both in my Gmod folder except the clientside one which should be downloaded automatically right?)

Place in Gamemodes and call it from init.lua and cl_init.lua would be eaiser

What the royal fuck was that mess of code that you just edited out? I guess you know none of it at all would work, and it would spam errors…

Flapjack, any idea why its not working when I try your code? (Few posts above)

Nope, I’ll test it…

Hm… It had a few errors (Which I fixed) but I’m getting this:

blockcommandscl.lua:8: stack overflow

I have no idea what it is… it’s the ‘For k , v in pairs’ loop which goes through blocked commands

I’m absolutely useless with LUA, not a clue about any of this :frowning:
If you do manage to figure it ouy that would be awesome.

Fixed that, but for some odd reason the code on the server infinate loops… very weird

Scratch that - it’s infinate looping on the client.

Fixed:

Serverside code:


FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*" , bantime = "0" }
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = "" , bantime = "13379001"}
function ServerCommand(ply , cmd , args)
	print("Command on server")
	newArgs = ""
	for k , v in pairs(args) do
		newArgs = newArgs.." "..v
	end
	file.Write("BannedMinges/"..ply:SteamID():gsub(":" , "_")..".txt" , os.date().."|"..ply:Nick().." Used command "..string.Explode("|" , args[1])[1].." with args "..string.Explode("|" , args[1])[2])
	print("Written file")
	
	for a , b in pairs(FuckYouList) do
		if cmd == b.cmd then
			ply:Ban(b.bantime  , "Minge")
			break
		end
	end
end
concommand.Add("MingeBanning" , ServerCommand)

Clientside code:



FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*"}
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = ""}

newEngineConCommand = engineConsoleCommand

function engineConsoleCommand(ply , cmd , args)
	if not LastRun then LastRun = -1 end
	if lastCommand == cmd and lastPly == ply and (CurTime() - LastRun) > -1 then return end
	print(ply:Nick() , cmd , args[1])
	cmdSafe = nil
	for k , v in pairs(FuckYouList) do
		print( k , v.cmd )
		if args[1] then
			if cmd == v.cmd then
				print("Command is the same")
				break
			else
				print("Command was different")
				cmdSafe = true
			end
		else
			if cmd == v.cmd then
				print("Command is the same + no args")
				break
			else
				print("Commands was different + no args")
				cmdSafe = true
			end
		end
	end
	if cmdSafe == true then
		lastCommand = cmd
		lastPly = ply
		lastRun = CurTime()
		newEngineConCommand(ply , cmd , args)
	else
		RunConsoleCommand("MingeBanning" , cmd.."|"..args[1])
	end
end

Ok, I tried typing in +aimbot_scan and this popped up

] +aimbot_scan
Raxx +aimbot_scan nil
1 wire_button_model
Commands was different + no args
2 +aimbot_scan
Command is the same + no args

Wasn’t banned or anything, just that there.

ply:Ban doesn’t work on a listen server.

It’s on a dedicated server though :S

Fixed:

New server code:


FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*" , bantime = "0" }
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = "" , bantime = "13379001"}
function ServerCommand(ply , cmd , args)
	newArgs = ""
	for k , v in pairs(args) do
		newArgs = newArgs.." "..v
	end
	file.Write("BannedMinges/"..ply:SteamID():gsub(":" , "_")..".txt" , os.date().."|"..ply:Nick().." Used command "..string.Explode("|" , args[1])[1].." with args "..string.Explode("|" , args[1])[2])
	
	for a , b in pairs(FuckYouList) do
		if string.Explode("|" , args[1])[1] == b.cmd then
			ply:Ban(b.bantime  , "Minge")
			break
		end
	end
end
concommand.Add("MingeBanning" , ServerCommand)

Edit: I’ll take the print statements out as well…

Clientside code:


FuckYouList = {}
FuckYouList[1] = {cmd = "wire_button_model" , args = "*"}
FuckYouList[2] = {cmd = "+aimbot_scan"  , args = ""}

newEngineConCommand = engineConsoleCommand

function engineConsoleCommand(ply , cmd , args)
	if not LastRun then LastRun = -1 end
	if lastCommand == cmd and lastPly == ply and (CurTime() - LastRun) > -1 then return end
	cmdSafe = nil
	for k , v in pairs(FuckYouList) do
		if args[1] then
			if cmd == v.cmd then
				break
			else
				cmdSafe = true
			end
		else
			if cmd == v.cmd then
				break
			else
				cmdSafe = true
			end
		end
	end
	if cmdSafe == true then
		lastCommand = cmd
		lastPly = ply
		lastRun = CurTime()
		newEngineConCommand(ply , cmd , args)
	else
		RunConsoleCommand("MingeBanning" , cmd.."|"..args[1])
	end
end