Advertisement
captmicro

first gmod esp (2009)

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