Gmod Anti-Exploit Custom Ban help

I am trying to override it to ban through sourcebans instead of the default gmod ban function by emulating a console command. However, it doesn’t work. The original works fine.

Custom Edit

[lua]local e_log = true
local e_filename = “ae_log.txt”
local scan_interval = 0.5
local exploit = “”

local name = ent:CPPIGetOwner():name()

function LogExploit(pl, expl, cla)
if e_log then
local NAM = “”
local SID = “”

	if pl == nil then
		NAM = "Unknown name"
		SID = "Unknown steamid"
	else
		NAM = pl:Nick( )
		SID = pl:SteamID()
	end
	if file.Exists( e_filename ) then
		file.Write( e_filename, file.Read( e_filename ) .. "

" … tostring( os.date() ) … " || " … NAM … " || " … SID … " || " … expl … " || " … cla )
else
file.Write( e_filename, tostring( os.date() ) … " || " … NAM … " || " … SID … " || " … expl … " || " … cla)
end
end
end

function UseTool( pl, tr, toolmode )
if CLIENT then return true end

if toolmode == "material" then
	exploit = "Material Exploit (Material tool)"
	if string.find( string.lower( pl:GetInfo( "material_override" ) ), "ar2_altfire1" ) then
		LogExploit(pl, exploit, pl:GetInfo( "material_override" ))
		game.ConsoleCommand("sm_ban "..name.." 0 Exploiting. Nice Try

")
pl:Kick(“Exploiting. Nice Try”)
return false
end
end

if toolmode == "door" or toolmode == "wired_door" then
	exploit = "Door Exploit"
	if pl:GetInfo( "door_class" ) == "prop_dynamic" or pl:GetInfo( "door_class" ) == "prop_door_rotating" then else
		LogExploit(pl, exploit, pl:GetInfo( "door_class" ))
		game.ConsoleCommand("sm_ban "..name.." 0 Exploiting. Nice Try

")
pl:Kick(“Exploiting. Nice Try, faggot.”)
return false
end
end

if toolmode == "trails" then
	exploit = "Material Exploit (Trails tool)"
	if string.find( string.lower( pl:GetInfo( "trails_material" ) ), "ar2_altfire1" ) then
		LogExploit(pl, exploit, pl:GetInfo( "trails_material" ))
		game.ConsoleCommand("sm_ban "..name.." 0 Exploiting. Nice Try

")
pl:Kick(“Exploiting. Nice Try”)
return false
end
end
return true
end

hook.Add( “CanTool”, “UseTool”, UseTool )

timer.Create( “scan_exploit”, scan_interval, 0,
function()
exploit = “Material Exploit (Other)”
for _, ent in pairs( ents.GetAll() ) do
if string.find( string.lower( ent:GetMaterial() ), “ar2_altfire1” ) then
if ent:IsPlayer() then
LogExploit(ent, exploit, ent:GetMaterial() … " (Player)")
game.ConsoleCommand("sm_ban “…name…” 0 Exploiting. Nice Try
“)
ent:Kick(“Exploiting. Nice Try”)
elseif ValidEntity( ent:GetOwner() ) then
LogExploit(ent:GetOwner(), exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)”)
game.ConsoleCommand("sm_ban “…name…” 0 Exploiting. Nice Try
“)
ent:CPPIGetOwner():Kick(“Exploiting. Nice Try”)
ent:Remove()
elseif SPropProtection then
LogExploit(ent:CPPIGetOwner(), exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)”)
game.ConsoleCommand("sm_ban “…name…” 0 Exploiting. Nice Try
“)
ent:CPPIGetOwner():Kick(“Exploiting. Nice Try”)
ent:Remove()
else
LogExploit(nil, exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)”)
ent:Remove()
end
end
end
end)[/lua]

Original

[lua]local e_log = true
local e_filename = “ae_log.txt”
local scan_interval = 0.5
local exploit = “”

function LogExploit(pl, expl, cla)
if e_log then
local NAM = “”
local SID = “”

	if pl == nil then
		NAM = "Unknown name"
		SID = "Unknown steamid"
	else
		NAM = pl:Nick( )
		SID = pl:SteamID()
	end
	if file.Exists( e_filename ) then
		file.Write( e_filename, file.Read( e_filename ) .. "

" … tostring( os.date() ) … " || " … NAM … " || " … SID … " || " … expl … " || " … cla )
else
file.Write( e_filename, tostring( os.date() ) … " || " … NAM … " || " … SID … " || " … expl … " || " … cla)
end
end
end

function UseTool( pl, tr, toolmode )
if CLIENT then return true end

if toolmode == "material" then
	exploit = "Material Exploit (Material tool)"
	if string.find( string.lower( pl:GetInfo( "material_override" ) ), "ar2_altfire1" ) then
		LogExploit(pl, exploit, pl:GetInfo( "material_override" ))
		pl:Ban(0,"Exploiting. Nice Try")
		pl:Kick("Exploiting. Nice Try")
		return false
	end
end

if toolmode == "door" or toolmode == "wired_door" then
	exploit = "Door Exploit"
	if pl:GetInfo( "door_class" ) == "prop_dynamic" or pl:GetInfo( "door_class" ) == "prop_door_rotating" then else
		LogExploit(pl, exploit, pl:GetInfo( "door_class" ))
		pl:Kick("Exploiting. Nice Try, faggot.")
		return false
	end
end

if toolmode == "trails" then
	exploit = "Material Exploit (Trails tool)"
	if string.find( string.lower( pl:GetInfo( "trails_material" ) ), "ar2_altfire1" ) then
		LogExploit(pl, exploit, pl:GetInfo( "trails_material" ))
		pl:Ban(0,"Exploiting. Nice Try")
		pl:Kick("Exploiting. Nice Try")
		return false
	end
end
return true

end

hook.Add( “CanTool”, “UseTool”, UseTool )

timer.Create( “scan_exploit”, scan_interval, 0,
function()
exploit = “Material Exploit (Other)”
for _, ent in pairs( ents.GetAll() ) do
if string.find( string.lower( ent:GetMaterial() ), “ar2_altfire1” ) then
if ent:IsPlayer() then
LogExploit(ent, exploit, ent:GetMaterial() … " (Player)")
ent:Ban(0,“Exploiting. Nice Try”)
ent:Kick(“Exploiting. Nice Try”)
elseif ValidEntity( ent:GetOwner() ) then
LogExploit(ent:GetOwner(), exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)")
ent:GetOwner():Ban(0,“Exploiting. Nice Try”)
ent:CPPIGetOwner():Kick(“Exploiting. Nice Try”)
ent:Remove()
elseif SPropProtection then
LogExploit(ent:CPPIGetOwner(), exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)")
ent:CPPIGetOwner():Ban(0,“Exploiting. Nice Try”)
ent:CPPIGetOwner():Kick(“Exploiting. Nice Try”)
ent:Remove()
else
LogExploit(nil, exploit, ent:GetMaterial() … " (Entity “… ent:GetClass() …”)")
ent:Remove()
end
end
end
end)[/lua]

Anyone see the error?

how about giving us your error?

The error is simple. Nothing is returned and the exploiter isn’t banned.

I thought the ar2_altfire material exploit was fixed?

Try
game.ConsoleCommand("sm_ban “…sql.SQLStr(name)…” 0 Exploiting. Nice Try
")

Pretty sure Sourcemod needs quotes around the name.
EDIT: Does local name = ent:CPPIGetOwner():name() even work? You should really check your server console as it boots up, for any errors.

You might be better doing:
game.ConsoleCommand(“sm_ban #”…pl:UserID()…" 0 Exploiting. Nice Try
")
to avoid any problems with blank/duplicate names, etc.

If you are using Lexi’s sourceban module this is tons easier.

If you’re not then why?

http://lexi.org.uk/modules/sourcebans.html

http://speedcap.net/img/Sam86/d22f7dc.png

Makes it so damn easy to hook SourceBans into any Admin mod.