Advertisement
captmicro

first gmod esp (2009)

Nov 27th, 2012
515
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.88 KB | None | 0 0
  1. --Hp tracker
  2. --(c)Capt. Micro
  3. --Do not redistribute
  4. --Modify to fit your needs (color only, mess with other stuff and shit happens)
  5. --Ask for permission before using in anything
  6. --Do not make table
  7. onTable={}
  8. --Screen cords
  9. W = ScrW()
  10. H = ScrH()
  11. --Colors
  12. --Hp colors
  13. HP_H = Color(0,255,0,255)
  14. HP_M = Color(255,125,0,255)
  15. HP_L = Color(255,0,0,255)
  16. --Armor colors
  17. ARMOR_H = Color(255,128,0,255)
  18. ARMOR_M = Color(255,158,61,255)
  19. ARMOR_L = Color(255,189,122,255)
  20. --Team colors
  21. T_F = Color(0,255,0,255)
  22. T_E = Color(255,0,0,255)
  23. T_D = Color(0,0,0,255)
  24. --Disance colors
  25. D_C = Color(0,255,0,255)
  26. D_M = Color(0,170,0,255)
  27. D_F = Color(0,85,0,255)
  28. --Box color
  29. B_D = Color(0,255,255,(255/4))
  30. --Main
  31. function DoHpTrack()
  32.     for p, v in pairs(onTable) do
  33.         Ph = 40*(p)
  34.         draw.RoundedBox(4, 12, Ph, W/10+10, H/30+13, B_D)
  35.         --name
  36.         x_p = 14
  37.         text=v:Nick()
  38.         N_col = Color(0,0,0,0)
  39.         if v:Team() == LocalPlayer():Team() then
  40.             N_col = T_F
  41.         elseif v:Team() ~= LocalPlayer():Team() then
  42.             N_col = T_E
  43.         else
  44.             N_col = T_D
  45.         end
  46.         draw.SimpleText(text, "Default", x_p, Ph, N_col, TEXT_ALIGN_LEFT)
  47.         --hp
  48.         x_p = 14
  49.         y_off = 12
  50.         t_hp = math.floor(v:Health())
  51.         text="[HP:"..t_hp.."]"
  52.         H_col = Color(0,0,0,0)
  53.         if t_hp > 75 then
  54.             H_col = HP_H
  55.         elseif t_hp > 45 and t_hp < 75 then
  56.             H_col = HP_M
  57.         elseif t_hp > 0 and t_hp < 45 then
  58.             H_col = HP_L
  59.         else
  60.             H_col=Color(0,0,0,255)
  61.         end
  62.         draw.SimpleText(text, "Default", x_p, Ph+y_off, H_col, TEXT_ALIGN_LEFT)
  63.         --armor
  64.         x_p = 14+43
  65.         y_off = 12
  66.         t_armor = v:Armor()
  67.         text="[ARMOR:"..t_armor.."]"
  68.         A_col = Color(0,0,0,0)
  69.         if t_armor > 75 then
  70.             A_col = ARMOR_H
  71.         elseif t_armor > 45 and t_armor < 75 then
  72.             A_col = ARMOR_M
  73.         elseif t_armor > 0 and t_armor < 45 then
  74.             A_col = ARMOR_L
  75.         else
  76.             A_col=Color(0,0,0,255)
  77.         end
  78.         draw.SimpleText(text, "Default", x_p, Ph+y_off, A_col, TEXT_ALIGN_LEFT)
  79.         --distance
  80.         x_p = 14
  81.         y_off = 24
  82.         h_you = LocalPlayer():GetPos()
  83.         h_them = v:GetPos()
  84.         h_dist = (h_you-h_them):Length()
  85.         h_disance = h_dist/10
  86.         text="[DIST:"..h_disance.."]"
  87.         D_col = Color(0,0,0,0)
  88.         if (h_disance > 1000) then
  89.             D_col = D_F
  90.         elseif (h_disance > 500) and (h_disance < 1000) then
  91.             D_col = D_M
  92.         elseif (h_disance > 0) and (h_disance < 500) then
  93.             D_col = D_C
  94.         else
  95.             D_col = Color(0,0,0,255)
  96.             text="[DIST:you]"
  97.         end
  98.         draw.SimpleText(text, "Default", x_p, Ph+y_off, D_col, TEXT_ALIGN_LEFT)
  99.     end
  100. end
  101. hook.Add("HUDPaint", "HpTracker", DoHpTrack)
  102. --VGUI
  103. function VGUI_T()
  104.     Frame = vgui.Create( "Frame" )
  105.     Frame:SetSize(ScrW()*0.30,ScrH()*0.44)
  106.     Frame:SetPos(ScrW()/2, ScrH()/2)
  107.     Frame:PostMessage( "SetTitle", "text", "Hp Tracker v1.3" )
  108.     Frame:SetVisible(true)
  109.     Frame:MakePopup()
  110.     Frame.topL = vgui.Create("Label", Frame)
  111.     Frame.topL:SetPos(15,25)
  112.     Frame.topL:SetText("     -Name-                      -Draw on/off-")
  113.     Frame.topL:SizeToContents()
  114.     for k,v in pairs(player.GetAll()) do
  115.         --label
  116.         label = vgui.Create("Label", Frame)
  117.         label:SetPos(15,25*(k+1))
  118.         draw_yn = ""
  119.         label:SetText(""..v:Nick().."")
  120.         label:SizeToContents()
  121.         --Button (draw on/off)
  122.         Btn = vgui.Create("Button", Frame)
  123.         Btn:SetText("Off")
  124.         Btn:SetPos(155, 25*(k+1))
  125.         Btn:SetWide(52)
  126.         function Btn:DoRightClick()
  127.             if not table.HasValue(onTable, v) then
  128.                 return
  129.             else
  130.                 self:SetText("On")
  131.                 for p,n in pairs(onTable) do
  132.                     if n:Nick() == v:Nick() then
  133.                         table.remove(onTable, p)
  134.                     end
  135.                 end
  136.             end
  137.         end
  138.         function Btn:DoClick()
  139.             if table.HasValue(onTable, v) then
  140.                 return
  141.             else
  142.                 self:SetText("Off")
  143.                 table.insert(onTable, v)
  144.             end
  145.         end
  146.     end
  147. end
  148. function on()
  149.     VGUI_T()
  150. end
  151. concommand.Add("HpTracker", on)
  152. function usrDis(ply)
  153.     for p,n in pairs(onTable) do
  154.         if n:Nick() == v:Nick() then
  155.             table.remove(onTable, p)
  156.         end
  157.     end
  158. end
  159. hook.Add( "PlayerDisconnected", "hptrackdisconnect", usrDis )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement