Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddCSLuaFile("autorun/client/antispam.lua")
- local banned = { "models/props_buildings/CollapsedBuilding01a.mdl" } //some props have weird volumes, manually blacklist them here
- local vollimit = 1770000 //props with a physics volume larger than this will be blocked
- local maxwarn = 10 //maximum spam warnings after which a user is kicked
- local interval = 1 //time (in seconds) between each valid prop spawn
- local cooldown = 10 //time (in seconds) after which the player's warning count is reset (provided they didn't spam during the cooldown)
- function AntiSpam(ply, mdl, ent)
- //if (ply:IsAdmin()) then return true end
- local vol = ent:GetPhysicsObject():GetVolume()
- if (table.HasValue(banned, mdl)) then
- ent:Remove()
- umsg.Start("ASMsg.Block", ply)
- umsg.End()
- return true
- end
- if (vol > vollimit) then
- ent:Remove()
- umsg.Start("ASMsg.Limit", ply)
- umsg.Long(vol)
- umsg.Long(vollimit)
- umsg.End()
- return true
- end
- if (ply.LastSpawnedTime + interval > CurTime()) then
- ent:Remove()
- ply.SpamWarnings = ply.SpamWarnings + 1
- ply.LastSpammed = CurTime()
- umsg.Start("ASMsg.Warn", ply)
- umsg.Short(ply.SpamWarnings)
- umsg.Short(maxwarn)
- umsg.End()
- if (ply.SpamWarnings >= maxwarn) then ply:Kick("Spamming") end
- return true
- else
- ply.LastSpawnedTime = CurTime()
- end
- end
- function SpamWarningDecay()
- for k, ply in pairs(player.GetAll()) do
- if ply.LastSpammed + cooldown < CurTime() and ply.SpamWarnings > 0 then
- ply.SpamWarnings = 0
- end
- end
- end
- hook.Add("Think", "SpamWarningDecay", SpamWarningDecay)
- hook.Add("PlayerSpawnedProp", "antispam", AntiSpam)
- 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