Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.38 KB | None | 0 0
  1. if not SERVER then return end if CLIENT then return end
  2. APA = (APA and APA.Settings) and APA or {Settings = {}} -- Do not remove.
  3. local defaults = defaults or {}
  4.  
  5. local RunConsoleCommand = RunConsoleCommand
  6. local cvars = cvars
  7. local timer = timer
  8. local hook = hook
  9.  
  10. APA.Settings = {
  11.     --- Base AntiPK ---
  12.     AntiPK                  = {1, "Setting this to 1 will enable Anti Prop Kill."},
  13.     Debug                   = {0, "Setting this to 1 will enable Debug Output. Setting this to 2 will log the output. (Warning: This command is spammy!)"},
  14.     PhysgunNerf             = {1, "Setting this to 1 will limit the physgun speed."},
  15.     BlockVehicleDamage      = {1, "Setting this to 1 will stop vehicle damage."},
  16.     BlockExplosionDamage    = {1, "Setting this to 1 will block explosion damage."},
  17.     BlockWorldDamage        = {0, "Setting this to 1 will block world damage."},
  18.     BlockPropDamage         = {0, "Setting this to 1 will always block \"prop_\" damage."},
  19.     KillOwnership           = {0, "Setting this to 1 will reward kills for \"prop_\" damage based on the props owner. (Warning: Due to possible entropy this may not be accurate!)"},
  20.     Method                  = {0, "Setting this to 1 will use the Blacklist, setting it to 0 will predict."},
  21.     OnlyPlayers             = {0, "Setting this to 1 will block damage on players only."},
  22.     PropsOnly               = {0, "Setting this to 1 will effect only \"prop_\" classes."},
  23.     BadTime                 = {0.15, "How long (in seconds) does an entity have to wait to become \"good\" and be able to do damage again. (Minimum is 0.15)"},
  24.     --- Prop Control ---
  25.     PropsNoCollide          = {1, "Setting this to 1 will make unfrozen props nocollide with eachother."},
  26.     UnbreakableProps        = {0, "Setting this to 1 will make props unbreakable."},
  27.     NoCollideVehicles       = {1, "Setting this to 1 will make vehicles not collide with players."},
  28.     AnnoySurf               = {1, "Setting this to 1 will make prop surf annoying."},
  29.     NoThrow                 = {1, "Setting this to 1 will stop people from throwing props."},
  30.     MaxMass                 = {1500, "This is the max weight a /spawned/ object may have. Minimum is 1, 0 Disables."},
  31.     --- Freezing ---
  32.     StopMassUnfreeze        = {1, "Setting this to 1 will stop people from unfreezing all their props by double tapping R."},
  33.     StopRUnfreeze           = {0, "Setting this to 1 will stop people from unfreezing props by tapping R."},
  34.     FreezeOnHit             = {1, "Setting this to 1 will freeze props when they hit a player. (Needs AntiPK.)"},
  35.     FreezeOnDrop            = {0, "Setting this to 1 will freezes props when a player lets go of them."},
  36.     FreezeOnUnghost         = {1, "Setting this to 1 will freeze props when they unghost."},
  37.     FreezePassive           = {0, "Setting this to 1 will freeze props passivly."},
  38.     --- Ghosting ---
  39.     GhostPickup             = {1, "Setting this to 1 will enable ghosting props on pickup."},
  40.     GhostSpawn              = {0, "Setting this to 1 will enable ghosting on spawn."},
  41.     GhostFreeze             = {0, "Setting this to 1 will freeze ghosts."},
  42.     UnGhostPassive          = {1, "Setting this to 1 will passivly unghost props. (Needs AntiPush.)"},
  43.     GhostsNoCollide         = {0, "Setting this to 1 will make ghosts nocollide with everything."},
  44. }
  45.  
  46. APA.Settings.L = {
  47.     Freeze = {"prop_physics", "gmod_button", "gmod_", "lawboard", "light", "lamp", "jail", "wire"},
  48.     Black  = {"prop_physics", "gmod_", "money", "printer", "cheque", "light", "lamp", "wheel", "playx", "radio", "lawboard", "fadmin", "jail", "prop", "wire", "media"},
  49.     White  = {"player", "npc", "weapon", "knife", "grenade", "prop_combine_ball", "npc_tripmine", "npc_satchel", "prop_door_", "trigger_", "env_"},
  50.     Damage = { DMG_CRUSH, DMG_SLASH, DMG_CLUB, DMG_DIRECT, DMG_PHYSGUN, DMG_VEHICLE }
  51. }
  52.  
  53. ---------------------------------------------------------
  54.  
  55. local include = include
  56. local function plugin(a)
  57.     local a = tostring(a)
  58.     MsgN('> '..a:gsub('^%l',string.upper))
  59.     include('modules/apa/'..a..'.lua')
  60. end
  61.  
  62. APA.Settings.M = APA.Settings.M or {}
  63. for k,v in next, APA.Settings do -- Build Cvars.
  64.     if k ~= 'L' and k ~= 'M' then
  65.         APA.Settings[k] = CreateConVar(string.lower("apa_"..tostring(k)), v[1], {FCVAR_DEMO, FCVAR_GAMEDLL, FCVAR_SERVER_CAN_EXECUTE, FCVAR_REPLICATED, FCVAR_NOTIFY}, v[2])
  66.         defaults[k] = {string.Replace(tostring(v[1]), ".00", ""), v[2]}
  67.     end
  68. end
  69.  
  70. APA.hasCPPI = CPPI and CPPI.GetVersion and CPPI.GetVersion() and true or false
  71. APA.PostEntity = false
  72.  
  73. function APA.initPlugin(plugin)
  74.     local plugin = tostring(plugin)
  75.     timer.Simple(0, function()
  76.         APA.Settings.M = APA.Settings.M or {}
  77.         APA.Settings.M[plugin:gsub('^%l',string.upper)] = true
  78.     end)
  79. end
  80.  
  81. cvars.AddChangeCallback(APA.Settings.PhysgunNerf:GetName(), function( v, o, n )
  82.     APA.physgun_maxSpeed = APA.physgun_maxSpeed or GetConVar("physgun_maxSpeed"):GetInt()
  83.     if tobool(n) then
  84.         RunConsoleCommand("physgun_maxSpeed", "975")
  85.     else
  86.         RunConsoleCommand("physgun_maxSpeed", tostring(APA.physgun_maxSpeed))
  87.     end
  88. end)
  89.  
  90. cvars.AddChangeCallback(APA.Settings.AntiPK:GetName(), function(v, o, n)
  91.     if not tobool(n) then
  92.         for _,v in next, player.GetAll() do
  93.             if IsValid(v) and (v:IsAdmin() or v:IsSuperAdmin()) then
  94.                 APA.Notify(v, "WARNING: APAnti Disabled!", NOTIFY_ERROR, 3.5, 1)
  95.             end
  96.         end
  97.     end
  98. end)
  99.  
  100. hook.Add("PostGamemodeLoaded", "APAntiLOAD", function()
  101.     MsgN("          _____              _   _ ")
  102.     MsgN("    /\\   |  __ \\ /\\         | | (_)")
  103.     MsgN("   /  \\  | |__) /  \\   _ __ | |_ _ ")
  104.     MsgN("  / /\\ \\ |  ___/ /\\ \\ | '_ \\| __| |")
  105.     MsgN(" / ____ \\| |  / ____ \\| | | | |_| |")
  106.     MsgN("/_/    \\_\\_| /_/    \\_\\_| |_|\\__|_|")
  107.     MsgN("-         -          -   Loading...")
  108.     APA.hasCPPI = CPPI and CPPI.GetVersion and CPPI.GetVersion() and true or false
  109.     if not APA.hasCPPI then
  110.         MsgC( Color(255, 0, 0), "\n\n---------------------------------------------------------------")
  111.         MsgC( Color( 255, 0, 0 ), "\n| [APA] ERROR: CPPI not found, Prop Protection not installed? |")
  112.         MsgC( Color(255, 0, 0), "\n---------------------------------------------------------------\n")
  113.         MsgC( Color(255, 0, 0), "\nYou need any CPPI based prop protection installed. (FPP, PatchProtect, UPS, etc.)\n")
  114.         ErrorNoHalt("[APA] CPPI not found, APAnti will be heavily limited.")  MsgN("\n")
  115.     end
  116.  
  117.     include('sv_apanti.lua')
  118.  
  119.     timer.Simple(0, function()
  120.         if APA.Settings.PhysgunNerf:GetBool() then
  121.             APA.physgun_maxSpeed = APA.physgun_maxSpeed or GetConVar("physgun_maxSpeed"):GetInt()
  122.             RunConsoleCommand("physgun_maxSpeed", "950")
  123.         end
  124.  
  125.         MsgN('\n-------------------------')
  126.         MsgN('|APAnti - Plugins Called|')
  127.         APA.Settings.M = APA.Settings.M or {}
  128.         local plugins, _ = file.Find('modules/apa/*.lua','LUA')
  129.         for _,v in next, plugins do
  130.             if v then
  131.                 v = string.gsub(tostring(v),'%.lua','')
  132.                 APA.Settings.M[v:gsub('^%l',string.upper)] = false
  133.                 plugin(v)
  134.             end
  135.         end
  136.         MsgN('|APAnti - Plugins Loaded|')
  137.         MsgN('-------------------------')
  138.         MsgN('APAnti is ready to go!')
  139.     end)
  140. end)
  141.  
  142. util.AddNetworkString("APAnti AlertNotice")
  143.  
  144. function APA.Notify(ply, str, ctype, time, alert, moreinfo)
  145.     if alert >= 1 or tobool(alert) then alert = 1 end
  146.  
  147.     if not IsValid(ply) then return end
  148.     if not (ply.IsPlayer and ply:IsPlayer()) then return end
  149.     if not str then return end
  150.     if not ctype then ctype = 1 end
  151.  
  152.     str,ctype,time,alert = tostring(str),tonumber(ctype),tonumber(time),tonumber(alert)
  153.  
  154.     if moreinfo then
  155.         for k,v in next, moreinfo do if( type(v) != "string" ) then moreinfo[k] = nil end end
  156.     else moreinfo = {} end
  157.  
  158.     net.Start("APAnti AlertNotice")
  159.         net.WriteString(str)
  160.         net.WriteFloat(ctype)
  161.         net.WriteFloat(time)
  162.         net.WriteFloat(alert)
  163.         net.WriteTable(moreinfo)
  164.     net.Send(ply)
  165. end
  166.  
  167. local shortcut_help = [[
  168. APAnti Shortcut Commands
  169.  
  170. "apa help"      = Info about all commands.
  171. "apa nolag"     = Quickly freeze all entities.
  172. "apa default"   = Restore defaults.
  173. ]]
  174.  
  175. concommand.Add("apa", function( ply, cmd, _, argStr )
  176.     if argStr == "help" then
  177.         print("Help and update notes can be found here...","https://github.com/LuaTenshi/APAnti/blob/TEST/README.md")
  178.     elseif argStr == "nolag" then
  179.         APA.NoLag()
  180.         print('[APA] Freezing entities...')
  181.     elseif argStr == "default" then
  182.         for k,v in next, defaults do
  183.             RunConsoleCommand("apa_"..k,v[1])
  184.         end
  185.     else
  186.         print(shortcut_help)
  187.     end
  188. end,
  189. function() return {"apa help", "apa nolag", "apa default"} end, shortcut_help,
  190. {FCVAR_DEMO, FCVAR_GAMEDLL, FCVAR_SERVER_CAN_EXECUTE})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement