Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. AddCSLuaFile("autorun/client/antispam.lua")
  2.  
  3. local banned = { "models/props_buildings/CollapsedBuilding01a.mdl" } //some props have weird volumes, manually blacklist them here
  4. local vollimit = 1770000 //props with a physics volume larger than this will be blocked
  5. local maxwarn = 10 //maximum spam warnings after which a user is kicked
  6. local interval = 1 //time (in seconds) between each valid prop spawn
  7. local cooldown = 10 //time (in seconds) after which the player's warning count is reset (provided they didn't spam during the cooldown)
  8.  
  9. function AntiSpam(ply, mdl, ent)
  10.     //if (ply:IsAdmin()) then return true end
  11.  
  12.     local vol = ent:GetPhysicsObject():GetVolume()
  13.    
  14.     if (table.HasValue(banned, mdl)) then
  15.         ent:Remove()
  16.         umsg.Start("ASMsg.Block", ply)
  17.         umsg.End()
  18.         return true
  19.     end
  20.    
  21.     if (vol > vollimit) then
  22.         ent:Remove()
  23.         umsg.Start("ASMsg.Limit", ply)
  24.         umsg.Long(vol)
  25.         umsg.Long(vollimit)
  26.         umsg.End()
  27.         return true
  28.     end
  29.    
  30.     if (ply.LastSpawnedTime + interval > CurTime()) then
  31.         ent:Remove()
  32.        
  33.         ply.SpamWarnings = ply.SpamWarnings + 1
  34.        
  35.         ply.LastSpammed = CurTime()
  36.        
  37.         umsg.Start("ASMsg.Warn", ply)
  38.         umsg.Short(ply.SpamWarnings)
  39.         umsg.Short(maxwarn)
  40.         umsg.End()
  41.        
  42.         if (ply.SpamWarnings >= maxwarn) then ply:Kick("Spamming") end
  43.         return true
  44.     else
  45.         ply.LastSpawnedTime = CurTime()
  46.     end
  47. end
  48.  
  49. function SpamWarningDecay()
  50.     for k, ply in pairs(player.GetAll()) do
  51.         if ply.LastSpammed + cooldown < CurTime() and ply.SpamWarnings > 0 then
  52.             ply.SpamWarnings = 0
  53.         end
  54.     end
  55. end
  56.  
  57. hook.Add("Think", "SpamWarningDecay", SpamWarningDecay)
  58. hook.Add("PlayerSpawnedProp", "antispam", AntiSpam)
  59. hook.Add("PlayerInitialSpawn", "antispamset", function(ply) ply.LastSpawnedTime = 0 ply.SpamWarnings = 0 ply.LastSpammed = 0 end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement