Guest User

Witnesses.lua

a guest
Apr 7th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1.     local Cap = math.cos(math.rad(45))
  2.     local Offset = Vector(0, 0, 32)
  3.     local Trace = {}
  4.  
  5.     function Draw()
  6.         local Time = os.time() - 1
  7.         local Witnesses = 0
  8.         local BeingWitnessed = true
  9.         local Texture = surface.GetTextureID("gui/silkicons/emoticon_smile")
  10.  
  11.         if Time < os.time() then
  12.             Time = os.time() + .5
  13.             Witnesses = 0
  14.             BeingWitnessed = false
  15.             for _, pl in pairs(player.GetAll()) do
  16.                 if pl:IsValid() && pl != LocalPlayer() then
  17.                     Trace.start  = LocalPlayer():EyePos() + Offset
  18.                     Trace.endpos = pl:EyePos() + Offset
  19.                     Trace.filter = {pl, LocalPlayer()}
  20.  
  21.                     TraceRes = util.TraceLine(Trace)
  22.  
  23.                     if !TraceRes.Hit then
  24.                         if (pl:EyeAngles():Forward():DotProduct((LocalPlayer():EyePos() - pl:EyePos()):Normalize()) > Cap) then
  25.                             Witnesses = Witnesses + 1
  26.                             BeingWitnessed = true
  27.                         end
  28.                     end
  29.                 end
  30.             end
  31.         end
  32.  
  33.         surface.SetFont("BudgetLabel")
  34.         if BeingWitnessed then
  35.             surface.SetTextColor(255, 000, 000, 255)
  36.             Texture = surface.GetTextureID("gui/silkicons/exclamation")
  37.         else
  38.             surface.SetTextColor(000, 255, 000, 255)
  39.             Texture = surface.GetTextureID("gui/silkicons/emoticon_smile")
  40.         end
  41.         local Text = "Witnesses: "..tostring(Witnesses)
  42.         local Width, Height = surface.GetTextSize(Text)
  43.  
  44.         surface.SetDrawColor(80, 80, 80, 180)
  45.         surface.DrawRect(ScrW()/2 - (Width/2 + 24), 4, Width + 28, Height + 8)
  46.         surface.SetDrawColor(0, 0, 0, 255)
  47.         surface.DrawOutlinedRect(ScrW()/2 - (Width/2 + 24), 4, Width + 28, Height + 8)
  48.  
  49.         surface.SetTexture(Texture)
  50.         surface.SetDrawColor(255, 255, 255, 255)
  51.         surface.DrawTexturedRect(ScrW()/2 - (Width/2 + 20), 8, 16, 16)
  52.         surface.SetTextPos(ScrW()/2 - Width/2, 8)
  53.         surface.DrawText(Text)
  54.     end
  55.     hook.Add("HUDPaint", "WitnessesBox", Draw)
Advertisement
Add Comment
Please, Sign In to add comment