Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Hp tracker
- --(c)Capt. Micro
- --Do not redistribute
- --Modify to fit your needs (color only, mess with other stuff and shit happens)
- --Ask for permission before using in anything
- --(email) captmicro@gmail.com
- --Do not make table
- onTable={}
- --Screen cords
- W = ScrW()
- H = ScrH()
- --Colors
- --Hp colors
- HP_H = Color(0,255,0,255)
- HP_M = Color(255,125,0,255)
- HP_L = Color(255,0,0,255)
- --Armor colors
- ARMOR_H = Color(255,128,0,255)
- ARMOR_M = Color(255,158,61,255)
- ARMOR_L = Color(255,189,122,255)
- --Team colors
- T_F = Color(0,255,0,255)
- T_E = Color(255,0,0,255)
- T_D = Color(0,0,0,255)
- --Disance colors
- D_C = Color(0,255,0,255)
- D_M = Color(0,170,0,255)
- D_F = Color(0,85,0,255)
- --Box color
- B_D = Color(0,255,255,(255/4))
- --Main
- function DoHpTrack()
- for p, v in pairs(onTable) do
- Ph = 40*(p)
- draw.RoundedBox(4, 12, Ph, W/10+10, H/30+13, B_D)
- --name
- x_p = 14
- text=v:Nick()
- N_col = Color(0,0,0,0)
- if v:Team() == LocalPlayer():Team() then
- N_col = T_F
- elseif v:Team() ~= LocalPlayer():Team() then
- N_col = T_E
- else
- N_col = T_D
- end
- draw.SimpleText(text, "Default", x_p, Ph, N_col, TEXT_ALIGN_LEFT)
- --hp
- x_p = 14
- y_off = 12
- t_hp = math.floor(v:Health())
- text="[HP:"..t_hp.."]"
- H_col = Color(0,0,0,0)
- if t_hp > 75 then
- H_col = HP_H
- elseif t_hp > 45 and t_hp < 75 then
- H_col = HP_M
- elseif t_hp > 0 and t_hp < 45 then
- H_col = HP_L
- else
- H_col=Color(0,0,0,255)
- end
- draw.SimpleText(text, "Default", x_p, Ph+y_off, H_col, TEXT_ALIGN_LEFT)
- --armor
- x_p = 14+43
- y_off = 12
- t_armor = v:Armor()
- text="[ARMOR:"..t_armor.."]"
- A_col = Color(0,0,0,0)
- if t_armor > 75 then
- A_col = ARMOR_H
- elseif t_armor > 45 and t_armor < 75 then
- A_col = ARMOR_M
- elseif t_armor > 0 and t_armor < 45 then
- A_col = ARMOR_L
- else
- A_col=Color(0,0,0,255)
- end
- draw.SimpleText(text, "Default", x_p, Ph+y_off, A_col, TEXT_ALIGN_LEFT)
- --distance
- x_p = 14
- y_off = 24
- h_you = LocalPlayer():GetPos()
- h_them = v:GetPos()
- h_dist = (h_you-h_them):Length()
- h_disance = h_dist/10
- text="[DIST:"..h_disance.."]"
- D_col = Color(0,0,0,0)
- if (h_disance > 1000) then
- D_col = D_F
- elseif (h_disance > 500) and (h_disance < 1000) then
- D_col = D_M
- elseif (h_disance > 0) and (h_disance < 500) then
- D_col = D_C
- else
- D_col = Color(0,0,0,255)
- text="[DIST:you]"
- end
- draw.SimpleText(text, "Default", x_p, Ph+y_off, D_col, TEXT_ALIGN_LEFT)
- end
- end
- hook.Add("HUDPaint", "HpTracker", DoHpTrack)
- --VGUI
- function VGUI_T()
- Frame = vgui.Create( "Frame" )
- Frame:SetSize(ScrW()*0.30,ScrH()*0.44)
- Frame:SetPos(ScrW()/2, ScrH()/2)
- Frame:PostMessage( "SetTitle", "text", "Hp Tracker v1.3" )
- Frame:SetVisible(true)
- Frame:MakePopup()
- Frame.topL = vgui.Create("Label", Frame)
- Frame.topL:SetPos(15,25)
- Frame.topL:SetText(" -Name- -Draw on/off-")
- Frame.topL:SizeToContents()
- for k,v in pairs(player.GetAll()) do
- --label
- label = vgui.Create("Label", Frame)
- label:SetPos(15,25*(k+1))
- draw_yn = ""
- label:SetText(""..v:Nick().."")
- label:SizeToContents()
- --Button (draw on/off)
- Btn = vgui.Create("Button", Frame)
- Btn:SetText("Off")
- Btn:SetPos(155, 25*(k+1))
- Btn:SetWide(52)
- function Btn:DoRightClick()
- if not table.HasValue(onTable, v) then
- return
- else
- self:SetText("On")
- for p,n in pairs(onTable) do
- if n:Nick() == v:Nick() then
- table.remove(onTable, p)
- end
- end
- end
- end
- function Btn:DoClick()
- if table.HasValue(onTable, v) then
- return
- else
- self:SetText("Off")
- table.insert(onTable, v)
- end
- end
- end
- end
- function on()
- VGUI_T()
- end
- concommand.Add("HpTracker", on)
- function usrDis(ply)
- for p,n in pairs(onTable) do
- if n:Nick() == v:Nick() then
- table.remove(onTable, p)
- end
- end
- end
- hook.Add( "PlayerDisconnected", "hptrackdisconnect", usrDis )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement