Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ----------------------------------------------------------------
- //Setting up some database stuff
- ----------------------------------------------------------------
- HUD = {}
- ICON = {}
- ICON.Health = surface.GetTextureID("hud/plus")
- ICON.Armor = surface.GetTextureID("hud/shield3")
- ----------------------------------------------------------------
- //Setting up some variables
- ----------------------------------------------------------------
- function PostEntity()
- ply = LocalPlayer()
- FakeHealth = LocalPlayer():Health()
- FakeArmor = LocalPlayer():Armor()
- len = 0
- Newlen = 0
- end
- hook.Add( "InitPostEntity", "MapStartTrigger", PostEntity )
- local NewName
- ----------------------------------------------------------------
- //All the HUD stuff
- ----------------------------------------------------------------
- function HUD.display()
- local ScrY = ScrH()/2; local ScrX = ScrH()/2;
- ----------------------------------------------------------------
- //HUD - Name
- ----------------------------------------------------------------
- StrLen = string.len(LocalPlayer():Nick())
- shortName = string.sub(ply:Nick(), 1, 23)
- if (StrLen >= 23) then
- DrawBox(ScrX-450, ScrY-500, Newlen+35, 18, 100, 100, 100, 100) -- Name BG Box
- DrawBoxLine(ScrX-450, ScrY-500, Newlen+35, 18, 230, 230, 230, 255) -- Name Box Line
- DrawText(shortName.."...", ScrX-441, ScrY-499, 255, 255, 255, 255) -- Name Text
- Newlen = surface.GetTextSize(shortName)
- end
- if (StrLen < 23) then
- DrawBox(ScrX-450, ScrY-500, len+20, 18, 100, 100, 100, 100) -- Name BG Box
- DrawText(ply:Nick(), ScrX-441, ScrY-499, 255, 255, 255, 255) -- Name Text
- len = surface.GetTextSize(ply:Nick())
- DrawBoxLine(ScrX-450, ScrY-500, len+20, 18, 230, 230, 230, 255) -- Name Box Line
- end
- ----------------------------------------------------------------
- //HUD - Health
- ----------------------------------------------------------------
- FakeHealth = math.Approach(FakeHealth, LocalPlayer():Health(), 0.4) --Slow health movement
- Frac = FakeHealth/100
- HPBar = math.Clamp(Frac,0,1)
- local color = 255 * math.Clamp(math.sin(CurTime()*4),0,1) -- Health flashing
- DrawBox(ScrX-450, ScrY-480, 20, 18, 100, 100, 100, 100) -- HP Icon BG Box
- DrawBox(ScrX-425, ScrY-478, 500, 14, 100, 100, 100, 100) -- HP Bar BG Box
- DrawBoxLine(ScrX-450, ScrY-480, 20, 18, 255, 255, 255, 255) -- Health Icon Box
- DrawTexture(ICON.Health, ScrX-448, ScrY-479, 16, 16, 255, 255, 255, 255) -- Health Icon
- DrawBoxLine(ScrX-425, ScrY-478, 500, 14, 255, 255, 255, 255) -- Health Box
- DrawBox(ScrX-422, ScrY-475, HPBar*494, 8, 255, 255, 255, 255) -- Health Bar
- if (LocalPlayer():Health()) <=40 then
- DrawBox(ScrX-422, ScrY-475, HPBar*494, 8, 255, 200, 0, 255)end -- Health Bar
- if (LocalPlayer():Health()) <=35 then
- DrawBox(ScrX-422, ScrY-475, HPBar*494, 8, 255, 100, 0, 255)end -- Health Bar
- if (LocalPlayer():Health()) <=25 then
- DrawBox(ScrX-422, ScrY-475, HPBar*494, 8, color, 0, 0, color)end -- Health Bar
- ----------------------------------------------------------------
- //HUD - Stamina
- ----------------------------------------------------------------
- FakeArmor = math.Approach(FakeArmor, LocalPlayer():Armor(), 0.4) --Slow health movement
- FracArm = FakeArmor/100
- ArmBar = math.Clamp(FracArm,0,1)
- DrawBox(ScrX-450, ScrY-460, 20, 18, 100, 100, 100, 100) -- Stamina Icon BG Box
- DrawBox(ScrX-425, ScrY-458, 500, 14, 100, 100, 100, 100) -- Stamina Bar BG Box
- DrawBoxLine(ScrX-450, ScrY-460, 20, 18, 255, 255, 255, 255) -- Stamina Icon Box
- DrawTexture(ICON.Armor, ScrX-448, ScrY-459, 16, 16, 255, 255, 255, 255) -- Stamina Icon
- DrawBoxLine(ScrX-425, ScrY-458, 500, 14, 255, 255, 255, 255) -- Stamina Bar Box
- DrawBox(ScrX-422, ScrY-455, ArmBar*494, 8, 255, 255, 255, 255) -- Stamina Bar
- -- DrawBox(ScrX-422, ScrY-455, Stamina, 8, 255, 200, 0, Stambeat)
- end
- hook.Add("HUDPaint", "DrawHUD", HUD.display)
- -------------------------------------------------------------------------
- //Custom functions -- Makes it easier to apply in the main function
- -------------------------------------------------------------------------
- function DrawBox(x, y, w, h, r, g, b, a)
- surface.SetDrawColor( r, g, b, a )
- surface.DrawRect(x, y, w, h)
- end
- function DrawBoxLine(x, y, w, h, r, g, b, a)
- surface.SetDrawColor( r, g, b, a )
- surface.DrawOutlinedRect(x, y, w, h)
- end
- function DrawText(text, x, y, r, g, b, a)
- surface.SetTextColor( r, g, b, a )
- surface.SetTextPos( x, y )
- surface.SetFont( "MenuLarge" )
- surface.DrawText( text )
- end
- function DrawTexture(tex, x, y, w, h, r, g, b, a)
- surface.SetDrawColor( r, g, b, a )
- surface.SetTexture( tex );
- surface.DrawTexturedRect( x, y, w, h);
- end
- -------------------------------------------------------------------------
- //Hide original HUD
- -------------------------------------------------------------------------
- function hidehud(name)
- for k, v in pairs({"CHudHealth", "CHudBattery", "CHudAmmo", "CHudSecondaryAmmo"}) do
- if name == v then return false end
- end
- end
- hook.Add("HUDShouldDraw", "HideOurHud:D", hidehud)
Add Comment
Please, Sign In to add comment