Advertisement
HK47

spawn protection

Nov 7th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. if CLIENT then
  2.     local function add_wf(data)
  3.         local ply = data:ReadEntity()
  4.         local model = data:ReadString()
  5.         local pos = data:ReadVector()
  6.        
  7.         if ply.clientm and ply.clientm:IsValid() then ply.clientm:Remove() end
  8.         ply.clientm = ClientsideModel(model)
  9.        
  10.         local cache_model = ply.clientm
  11.        
  12.         if not ply.clientm:IsValid() then return end
  13.         ply.clientm:SetPos(pos)
  14.         ply.clientm:SetModelScale(1.2, 0)
  15.         ply.clientm:SetRenderMode(RENDERMODE_TRANSALPHA)
  16.         ply.clientm:SetMaterial("models/vortigaunt/pupil")
  17.        
  18.         local a = 255
  19.        
  20.         hook.Add("Think", "remove_wireframe_tws" .. ply:EntIndex(), function()
  21.             if not ply:IsValid() then
  22.                 if cache_model and cache_model:IsValid() then cache_model:Remove() end
  23.                 hook.Remove("Think", "remove_wireframe_tws" .. ply:EntIndex())
  24.             end
  25.        
  26.             if ply.clientm and ply.clientm:IsValid() then
  27.                 if a <= 0 then
  28.                     hook.Remove("Think", "remove_wireframe_tws" .. ply:EntIndex())
  29.                     return
  30.                 end
  31.            
  32.                 a = a - 0.5
  33.                 ply.clientm:SetColor(Color(a * 3, 255, a * 3, a))
  34.                 ply.clientm:SetAngles(Angle(0, CurTime() * 150, 0))
  35.                 ply.clientm:SetSequence(3)
  36.             end
  37.         end)
  38.     end
  39.    
  40.     usermessage.Hook("make_wireframe_tws", add_wf)
  41.  
  42.     return
  43. end
  44.  
  45. hook.Add("PlayerSpawn", "tws_spawnprotect", function(ply)
  46.     if CLIENT then return end
  47.    
  48.     ply:GodEnable()
  49.    
  50.     local model = ply:GetModel()
  51.     local pos = ply:GetPos()
  52.    
  53.     umsg.Start("make_wireframe_tws")
  54.         umsg.Entity(ply)
  55.         umsg.String(model)
  56.         umsg.Vector(pos)
  57.     umsg.End()
  58.    
  59.     timer.Simple(6, function()
  60.         if IsValid(ply) then
  61.             ply:GodDisable()
  62.         end
  63.     end)
  64. end)
  65.  
  66. //blocker
  67.  
  68. hook.Add("PlayerSpawnSENT", "blocker_tws", function(ply, class)
  69.     if class == "sent_ball" then return false end
  70.     return true
  71. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement