Advertisement
Tenrys13

sh_tenrys_simple_hud_lowhpwarn

Jun 17th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. if SERVER then
  2.     --Low HP Warning
  3.     AddCSLuaFile()
  4.     util.AddNetworkString("HPLowSound")
  5.     hook.Add("EntityTakeDamage", "CheckPlayerHealth", function(ent, dmginfo)
  6.         if !dmginfo or !IsValid(ent) or !ent:IsPlayer() then return end
  7.  
  8.         if (ent:Health()-dmginfo:GetDamage()) <= 9 then
  9.             net.Start("HPLowSound")
  10.             net.Send(ent)
  11.         end
  12.     end)   
  13. else
  14.     net.Receive("HPLowSound", function(len)
  15.         if !IsValid(ply) then return end
  16.         timer.Create("HPLowSound_"..ply:EntIndex(), 5, 0, function()
  17.             if !IsValid(ply) or ply:Health() >= 10 then
  18.                 timer.Destroy("HPLowSound_"..ply:EntIndex())
  19.                 return
  20.             end
  21.             surface.PlaySound("buttons/button17.wav")
  22.         end)
  23.     end)
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement