Advertisement
TylerB

nosurf

Dec 12th, 2015
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. if CLIENT then return end
  2.  
  3. nosurf_enabled = CreateConVar("nosurf_enabled", "1", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "Should we reprimand players for trying to propsurf?")
  4. nosurf_admins = CreateConVar("nosurf_admins", "1", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "Should we also reprimand admins?")
  5. nosurf_maxspeed = CreateConVar("nosurf_maxspeed", "128", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "How fast should they have to be travelling to be killed?")
  6. nosurf_message = CreateConVar("nosurf_message", "nosurf | Propsurfing is not allowed.", {FVCAR_REPLICATED, FCVAR_ARCHIVE}, "What should they see in chat when they're killed?")
  7.  
  8. hook.Add("PhysgunPickup", "nosurf", function(ply, ent) ply.nosurf = ent end)
  9. hook.Add("PhysgunDrop", "nosurf", function(ply) ply.nosurf = nil end)
  10.  
  11. local function nosurf_handle(ent, data)
  12.     local delta = data.DeltaTime
  13.     local ent2 = data.HitEntity
  14.    
  15.     if not (IsValid(ent2) and ent2:IsPlayer()) then return end
  16.  
  17.     local normal = data.HitNormal
  18.     local speed = (ent2:GetVelocity() - data.TheirOldVelocity):Length()
  19.     local speed2 = data.Speed
  20.    
  21.     if (nosurf_admins:GetBool() and ent2:IsAdmin()) or not ent2:IsAdmin() then
  22.         if speed2 > nosurf_maxspeed:GetInt() or speed > nosurf_maxspeed:GetInt() then
  23.             if IsValid(ent2.nosurf) and (ent2.nosurf == ent) and not ent:IsOnGround() then
  24.                 local stop = hook.Call("PropSurfed", GM or  GAMEMODE, v, aim)
  25.                
  26.                 if not stop then
  27.                     ent2:Kill()
  28.                     ent2:ChatPrint(nosurf_message:GetString())
  29.                 end
  30.             end
  31.         end
  32.     end
  33. end
  34.  
  35. hook.Add("OnEntityCreated", "nosurf", function(ent)
  36.     if IsValid(ent) and not ent:IsPlayer() then
  37.         ent:AddCallback("PhysicsCollide", nosurf_handle)
  38.     end
  39. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement