Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if CLIENT then return end
- nosurf_enabled = CreateConVar("nosurf_enabled", "1", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "Should we reprimand players for trying to propsurf?")
- nosurf_admins = CreateConVar("nosurf_admins", "1", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "Should we also reprimand admins?")
- nosurf_maxspeed = CreateConVar("nosurf_maxspeed", "128", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "How fast should they have to be travelling to be killed?")
- nosurf_message = CreateConVar("nosurf_message", "nosurf | Propsurfing is not allowed.", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "What should they see in chat when they're killed?")
- hook.Add("PhysgunPickup", "nosurf", function(ply, ent) ply.nosurf = ent end)
- hook.Add("PhysgunDrop", "nosurf", function(ply) ply.nosurf = nil end)
- local function nosurf_handle(ent, data)
- local delta = data.DeltaTime
- local ent2 = data.HitEntity
- if not (IsValid(ent2) and ent2:IsPlayer()) then return end
- local normal = data.HitNormal
- local speed = (ent2:GetVelocity() - data.TheirOldVelocity):Length()
- local speed2 = data.Speed
- if (nosurf_admins:GetBool() and ent2:IsAdmin()) or not ent2:IsAdmin() then
- if speed2 > nosurf_maxspeed:GetInt() or speed > nosurf_maxspeed:GetInt() then
- if IsValid(ent2.nosurf) and (ent2.nosurf == ent) and not ent:IsOnGround() then
- local stop = hook.Call("PropSurfed", GM or GAMEMODE, v, aim)
- if not stop then
- ent2:Kill()
- ent2:ChatPrint(nosurf_message:GetString())
- end
- end
- end
- end
- end
- hook.Add("OnEntityCreated", "nosurf", function(ent)
- if IsValid(ent) and not ent:IsPlayer() then
- ent:AddCallback("PhysicsCollide", nosurf_handle)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement