1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Need help with a HUD (Not related to Clockwork.)

Discussion in 'Help' started by MistyPanda, Apr 29, 2014.

  1. MistyPanda

    MistyPanda I hate everything!

    I'm trying to add:

    Code:
    local ELEMENT = mhud.New("mHud Fps")
    local self = LocalPlayer
    
    /*(
            Desc:   Paints the Fps Function
    )*/
    function ELEMENT.Paint()
            local x, y = ScrW() / 2, ScrH() - 40
            mhud.DrawProgress(5, x, y, 180, 4, math.floor(1 / RealFrameTime()), 300, true)
    end
    
    ELEMENT:AddHook("HUDPaint", ELEMENT.Paint, "mhud_fps_paint")
    mhud.Register(ELEMENT)
    
    Trying to add that to this HUD:

    Code:
    surface.CreateFont( "namefont", {
     font = "Helvetica",
     size = 24,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "namefontsmall", {
     font = "Helvetica",
     size = 24,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "healthfont", {
     font = "Helvetica",
     size = 16,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "healthfont2", {
     font = "Helvetica",
     size = 20,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    local Health = 0
    local av
    local name
    local oldName
    
    local function DrawPlayerAvatar( p )	
    	av = vgui.Create("AvatarImage")
    	av:SetPos(20,ScrH() - 130)
    	av:SetSize(64, 64)
    	av:SetPlayer( p, 64 )
    end
    
    
    
    local function bizzahud()
    
    	draw.RoundedBox( 4, 10, ScrH() - 143, 392, 133, Color( 0, 0,0, 255 ) )
    	
    	local font
    	
    	surface.SetFont( "namefont" )
    	local PlayerName = LocalPlayer():Name()
    	local Width, Height = surface.GetTextSize(PlayerName)
    	if Width > 100 then
    		font = "namefontsmall"
    	else
    		font = "namefont"
    	end
    	
    	surface.SetFont( "namefontsmall" )
    	local wh, hw = surface.GetTextSize(PlayerName)
    	if font == "namefontsmall" and wh > 100 then
    		PlayerName = string.sub( LocalPlayer():Name(), 1, 18 )
    	end
    	
    	if font == "namefont" and Width < 100 then
    		local PlayerName = LocalPlayer():Name()
    	end
    	
    	draw.SimpleText( PlayerName, font, 150, ScrH() - 110, Color( 255, 255, 255 ) )
    	
    	local x, y = 30, ScrH() - 20
    	local localplayer = LocalPlayer()
    	Health = math.min(100, (Health == localplayer:Health() and Health) or Lerp(0.1, Health, localplayer:Health()))
    
    	local DrawHealth = math.Min(Health , 1)
    	local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))
    	draw.RoundedBox(4, 20 + 60, y - 33, 309 - 7, 16, Color(0,0,0,200))
    	if LocalPlayer():Health() > 0 then
    		draw.RoundedBox(4, 21 + 60, y - 32, (309 - 9) * DrawHealth, 14, Color(255,40,40,180))
    	end
    pos
    	draw.DrawText(math.Max(0, math.Round(localplayer:Health())), "healthfont", 302 / 2 + 80, y - 33, Color(255,255,255,200), 1, TEXT_ALIGN_CENTER)
    	
    	local armor = LocalPlayer():Armor()
    	draw.RoundedBox(4, 20 + 60, ScrH() - 34, 302, 16, Color(0,0,0,200))
    	if armor > 0 then
    		draw.RoundedBox(4, 21 + 60, ScrH() - 33, armor * 3, 14, Color(40,40,255,255))
    	end
    	draw.SimpleText(armor, "healthfont", 80 + 302 / 2, ScrH() - 33, Color(255,255,255,200), TEXT_ALIGN_CENTER)
    	
    	draw.SimpleText("Health:", "healthfont2", 20, ScrH() - 54, Color(255,255,255,255), TEXT_ALIGN_LEFT)
    	draw.SimpleText("Armor:", "healthfont2", 20, ScrH() - 36, Color(255,255,255,255), TEXT_ALIGN_LEFT)
    	if av then
    		return
    	else
    		DrawPlayerAvatar( LocalPlayer() )
    	end
    end
    hook.Add("HUDPaint", "HUDByMrIbizza", bizzahud)
    
    function disableCHUD(name)
    	if name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo" or name == "CHudSecondaryAmmo" then 
    		return false 
    	end
    end
    hook.Add("HUDShouldDraw", "disablethisshit", disableCHUD)
    
    Please help.
     
  2. diablo1675

    diablo1675 Guest

    Wish I could help you, but I'm not a coder. :(
     
  3. MistyPanda

    MistyPanda I hate everything!

  4. Polis

    Polis Guest

    Here you are.

    Code:
    local ELEMENT = mhud.New("mHud Fps")
    local self = LocalPlayer
    
    surface.CreateFont( "namefont", {
     font = "Helvetica",
     size = 24,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "namefontsmall", {
     font = "Helvetica",
     size = 24,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "healthfont", {
     font = "Helvetica",
     size = 16,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    surface.CreateFont( "healthfont2", {
     font = "Helvetica",
     size = 20,
     weight = 500,
     blursize = 0,
     scanlines = 0,
     antialias = true
    } )
    
    local Health = 0
    local av
    local name
    local oldName
    
    local function DrawPlayerAvatar( p )	
    	av = vgui.Create("AvatarImage")
    	av:SetPos(20,ScrH() - 130)
    	av:SetSize(64, 64)
    	av:SetPlayer( p, 64 )
    end
    
    
    
    local function bizzahud()
    
    	draw.RoundedBox( 4, 10, ScrH() - 143, 392, 133, Color( 0, 0,0, 255 ) )
    	
    	local font
    	
    	surface.SetFont( "namefont" )
    	local PlayerName = LocalPlayer():Name()
    	local Width, Height = surface.GetTextSize(PlayerName)
    	if Width > 100 then
    		font = "namefontsmall"
    	else
    		font = "namefont"
    	end
    	
    	surface.SetFont( "namefontsmall" )
    	local wh, hw = surface.GetTextSize(PlayerName)
    	if font == "namefontsmall" and wh > 100 then
    		PlayerName = string.sub( LocalPlayer():Name(), 1, 18 )
    	end
    	
    	if font == "namefont" and Width < 100 then
    		local PlayerName = LocalPlayer():Name()
    	end
    	
    	draw.SimpleText( PlayerName, font, 150, ScrH() - 110, Color( 255, 255, 255 ) )
    	
    	local x, y = 30, ScrH() - 20
    	local localplayer = LocalPlayer()
    	Health = math.min(100, (Health == localplayer:Health() and Health) or Lerp(0.1, Health, localplayer:Health()))
    
    	local DrawHealth = math.Min(Health , 1)
    	local Border = math.Min(6, math.pow(2, math.Round(3*DrawHealth)))
    	draw.RoundedBox(4, 20 + 60, y - 33, 309 - 7, 16, Color(0,0,0,200))
    	if LocalPlayer():Health() > 0 then
    		draw.RoundedBox(4, 21 + 60, y - 32, (309 - 9) * DrawHealth, 14, Color(255,40,40,180))
    	end
    pos
    	draw.DrawText(math.Max(0, math.Round(localplayer:Health())), "healthfont", 302 / 2 + 80, y - 33, Color(255,255,255,200), 1, TEXT_ALIGN_CENTER)
    	
    	local armor = LocalPlayer():Armor()
    	draw.RoundedBox(4, 20 + 60, ScrH() - 34, 302, 16, Color(0,0,0,200))
    	if armor > 0 then
    		draw.RoundedBox(4, 21 + 60, ScrH() - 33, armor * 3, 14, Color(40,40,255,255))
    	end
    	draw.SimpleText(armor, "healthfont", 80 + 302 / 2, ScrH() - 33, Color(255,255,255,200), TEXT_ALIGN_CENTER)
    	
    	draw.SimpleText("Health:", "healthfont2", 20, ScrH() - 54, Color(255,255,255,255), TEXT_ALIGN_LEFT)
    	draw.SimpleText("Armor:", "healthfont2", 20, ScrH() - 36, Color(255,255,255,255), TEXT_ALIGN_LEFT)
    	if av then
    		return
    	else
    		DrawPlayerAvatar( LocalPlayer() )
    	end
    end
    hook.Add("HUDPaint", "HUDByMrIbizza", bizzahud)
    
    function disableCHUD(name)
    	if name == "CHudHealth" or name == "CHudBattery" or name == "CHudAmmo" or name == "CHudSecondaryAmmo" then 
    		return false 
    	end
    end
    hook.Add("HUDShouldDraw", "disablethisshit", disableCHUD)
    
    
    local function ELEMENT.Paint()
            local x, y = ScrW() / 2, ScrH() - 40
            mhud.DrawProgress(5, x, y, 180, 4, math.floor(1 / RealFrameTime()), 300, true)
    end
    
    ELEMENT:AddHook("HUDPaint", ELEMENT.Paint, "mhud_fps_paint")
    mhud.Register(ELEMENT)
     
  5. MistyPanda

    MistyPanda I hate everything!

    Doesn't work.
     
  6. Polis

    Polis Guest

    It looks like they aren't meant to work together then.
     
  7. MistyPanda

    MistyPanda I hate everything!

    It is possible, my friend told me.
     
  8. Polis

    Polis Guest

    Go out and learn how to do it, don't complain that it doesn't work- and don't let me tell you they aren't meant to work together.

    If it /is/ possible, go do it.
     
  9. MistyPanda

    MistyPanda I hate everything!

    I'm not complaining. Just asking for simple help. As I'm bad with HUDs.
     
  10. Polis

    Polis Guest

    Did you read what I just said or did you completely disregard it?
     
  11. MistyPanda

    MistyPanda I hate everything!

     
  12. MrSky

    MrSky player:NotifyAll("hitler is best") Clockwork Customer

    Start with a simple HUD then lol, possibly the simplest is...

    Code:
    function HUDHide ( myhud )
        for k, v in pairs{"CHUDHealth", "CHUDBattery"} do 
    	  if myhud == v then return false end
    	end
    end	
    hook.Add("HUDShouldDraw", "HUDHide", HUDHide)
    
    function GM:HUDPaint() 
        self.BaseClass:HUDPaint() 
    	local pl = LocalPlayer() 
    	local HP = LocalPlayer():Health()
        local ARM = LocalPlayer():Armor()
        
        surface.CreateFont("ScoreboardTest", 40, 250, false, false, "MyF")	
        surface.SetTextColor( 20, 20, 80, 255)	
        surface.SetTextPos( 20, 20 )	
        surface.SetFont("MyF")	
        surface.DrawText( HP ) 	
        surface.DrawText( Armor ) 
    end 
    And this just prints the Health for now.
     
  13. MistyPanda

    MistyPanda I hate everything!

    Thank you.
     
  14. MrSky

    MrSky player:NotifyAll("hitler is best") Clockwork Customer

    No problem.
     

Previous Readers (Total: 0)