util.AddNetworkString( "leyac_cmd" ) LeyAC = {} LeyAC.Enabled = true if ( not LeyAC.Enabled ) then return end -- Hooks we don't like LeyAC.BadStuff = { "xray", "cheat", "esp", "hack", "hera", "hh", "faphack", "antiaim", "sethhack", "baconbot", "aimbot", "bypass", "lenny_", "amtoafl", "norecoil", "nospread", "manipulate_spread", "hl2_shotmanip", "hl2_ucmd_getprediciton", "CF_ManipulateShot", "dead_chams", "zedhack"} LeyAC.SyncConvars = {} --No, this is not supposed to stop every cheat, it's supposed to block public ones like you can find on mpgh. --It's not great yet, but it does it's job. --It doesn't have any special things making it impossible to bypass, or really hard, because the usual purchaser wouldn't be able --to set it up by himself. --Should work with any addon, but if it doesn't work with one tell me and I'll solve the problem. --If you find a way to bypass this, a bug, or a public cheat that this doesn't detect, tell me about it. -- Specific Convars and the values they are supposed to have, should have the same content as the LeyAC.BadCV table on the client LeyAC.SyncConvars["sv_cheats"] = "0" LeyAC.SyncConvars["sv_allowcslua"] = "0" LeyAC.SyncConvars["host_timescale"] = "1.0" --Specific Exceptions for the Data LeyAC.Exceptions = { "fcvar_cheat", "dofmodehack", "lua_cookiespew", "TEAM_HACK" } LeyAC.KickForCheating = true -- Kicks Cheaters LeyAC.BanForCheating = false -- Bans Cheaters LeyAC.BanForCheating_Time = 0 -- 0 = Perma, time in seconds LeyAC.HTMLForCheating = false -- Freezes Cheaters and shows them an URL ( Strips them of Weapons for safety ) LeyAC.HTMLForCheating_URL = "http://nyan.cat/" LeyAC.CustomCheck = false -- Custom check, in case you e.g. don't want your admins getting banned for cheating LeyAC.Respond_Time = 50 -- Time people have to respond with the pong LeyAC.CheckTime = 5 -- Interval in which players should be searched for cheats function LeyAC.ShouldCheck( ply ) if ( ply.LeyAC_DontCheck ) then return false end if ( ply:IsUserGroup("superadmin") ) then return false end if ( ply:IsUserGroup("admin") ) then return false end if ( ply:IsUserGroup("moderator") ) then return false end return true end function LeyAC.InitPlayer( ply ) if ( LeyAC.CustomCheck and not LeyAC.ShouldCheck(ply) or ply:IsBot() ) then ply:ChatPrint("[LeyAC] You won't be checked for cheats.") return end timer.Simple(5, function() if ( not ply ) then return end if ( not IsValid(ply) ) then timer.Simple(5, function() if ( not ply ) then return end if ( not LeyAC or not LeyAC.InitPlayer ) then return end LeyAC.InitPlayer(ply) end) return end ply.LeyAC_ToCheck = true ply.LeyAC_RespondTime = CurTime() + LeyAC.Respond_Time -- Max x secs for a respond end) end hook.Add("PlayerInitialSpawn", "LeyAC.InitPlayer", LeyAC.InitPlayer) function LeyAC.CheckPlayer( ply ) if ( not ply.LeyAC_RespondTime or not ply.LeyAC_ToCheck ) then return end if ( CurTime() > ply.LeyAC_RespondTime ) then ply:Kick("[LeyAC] You needed too long to respond !") return end --print("[LeyAC] Checking: " .. ply:Nick() ) net.Start("leyac_cmd") net.Send(ply) end timer.Create("LeyAC_CheckTime", LeyAC.CheckTime, 0, function() --print("[LeyAC] Checking Players...") for k,v in pairs(player.GetAll()) do LeyAC.CheckPlayer(v) end end) function LeyAC.LogCheater( ply, reason, screenshot ) local safeid = string.lower(string.gsub(ply:SteamID(), ":", "_")) local name = ply:Nick() if ( not file.Exists( "leyac", "DATA" ) ) then file.CreateDir( "leyac" ) end if ( not file.Exists( "leyac/" .. safeid, "DATA" ) ) then file.CreateDir( "leyac/" .. safeid ) end local str = os.date() .. " - Nick: " .. name .. " | IP: " .. ply:IPAddress() .. " | Cheating Infraction: " str = str .. reason str = str .. "\n" if ( not file.Exists( "leyac/" .. safeid .. "/cheater.txt", "DATA" ) ) then file.Write( "leyac/" .. safeid .. "/cheater.txt", str ) else file.Append( "leyac/" .. safeid .. "/cheater.txt", "\n" .. str ) end end function LeyAC.Punishment( ply, violations ) if ( ply.LeyAC_HasBeenPunished ) then return end ply.LeyAC_HasBeenPunished = true local reason = "" for k,v in pairs(violations) do reason = reason .. v .. ";" end LeyAC.LogCheater( ply, reason ) ErrorNoHalt( "[" .. ply:SteamID() .. "] " .. ply:Nick() .. " is a cheater: " .. reason .. " !\n") if ( LeyAC.BanForCheating ) then if ( ULib and ULib.ban ) then if ( GB_InsertBan ) then --you can change that SteamID, if you'd like to GB_InsertBan( ply:SteamID(), ply:Nick(), LeyAC.BanForCheating_Time, "Ley AC", "STEAM_0:1:38725115" ) else ULib.ban( ply, LeyAC.BanForCheating_Time, reason, "Ley AC") end else ply:Ban(0) end end if ( LeyAC.KickForCheating ) then ply:Kick("[LeyAC] Cheaters are bad, and you should feel bad.") end if ( LeyAC.HTMLForCheating ) then ply:Freeze( true ) ply:StripWeapons() ply:SendLua( [[ if ( not vgui ) then return end LocalPlayer():ConCommand('say IM A FAGGOT AND CHEAT XD') local l = vgui.Create("HTML") l:SetSize(ScrW(),ScrH()) l:OpenURL("]] .. LeyAC.HTMLForCheating_URL .. [[") l:Center() vgui = nil]]) end end function LeyAC.Cmd( l, ply ) if ( not ply.LeyAC_RespondTime or not ply.LeyAC_ToCheck ) then return end local data = net.ReadString() local violate = net.ReadString() if ( not violate ) then violate = { "Manipulating Data" } else violate = util.JSONToTable(violate) end if ( not data ) then data = {} violate = { "Manipulating Data" } else data = util.JSONToTable(data) end if ( not violate ) then violate = { "Manipulating Data" } end if ( not data ) then data = { "Manipulating Data" } end for k,v in pairs(data) do for a,b in pairs(LeyAC.BadStuff) do if ( string.find(string.lower(v), b) ) then table.insert(violate, v) end end end for k,v in pairs(violate) do for a,b in pairs(LeyAC.Exceptions) do if ( string.find(string.lower(v), b) ) then violate[k] = nil end end end local nv = {} for k,v in pairs(violate) do table.insert(nv, v) end violate = nv -- fix nums --PrintTable(violate) if ( violate[1] ) then LeyAC.Punishment( ply, violate ) else if ( not data or data == "" or not data[1] ) then LeyAC.Punishment( ply, "Manipulating Data") end end ply.LeyAC_RespondTime = CurTime() + 20 end net.Receive( "leyac_cmd", LeyAC.Cmd ) local TriedToFix = {} -- Prevent Server Owners from being dumb function LeyAC.Think( ) for k,v in pairs( LeyAC.SyncConvars ) do if ( not GetConVar(k) ) then continue end if ( GetConVar(k):GetString() != v and not TriedToFix[k] ) then RunConsoleCommand( k, v ) -- Let's try fixing it for him if ( GetConVar(k):GetString() != v ) then -- if it didn't work, tell him to do it RunConsoleCommand( "say", "Please tell the Server-Owner to set: " .. k .. " to " .. tostring(v) ) end TriedToFix[k] = true end end end hook.Add("Think", "LeyAC.Think", LeyAC.Think)