HUD | Icons issue

Okay so me and a friend are working on a HUD for DarkRP.

The problem is, the icons aren’t the silk icons, from what I know…

This is the code…



-- Health
       
        local Health = LocalPlayer():Health()
        local DrawHealth = math.Min(Health / GAMEMODE.Config.startinghealth, 1)
        draw.RoundedBox(10, Main + 8- 30-50, ScrH() - 47, 159, 34, Color(0,0,0,255))
        draw.RoundedBox(10, Main + 10- 30-50, ScrH() - 45, 155, 30, Color(64,64,64,255))
        draw.RoundedBox(10, Main + 10 - 30-50, ScrH() - 45, 155, 15, Color(89,89,89,255))
        draw.SimpleTextOutlined("Health:", "SexyFont", Main + 40-6-50, ScrH() - 41+2, Color(255,255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT, 1, Color(0,0,0,255) )
        draw.SimpleTextOutlined(Health, "SexyFont", Main + 115-6-50, ScrH() - 41+2, Color(255,0,0,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_LEFT, 1, Color(0,0,0,255) )
        surface.SetDrawColor(255,255,255)
        surface.SetTexture(surface.GetTextureID("gui/silkicons/heart"))
    surface.DrawTexturedRect(Main -15-50,ScrH() - 38,16,16)


But this is what the health looks like ingame… http://puu.sh/4ALql.png

Normally the huds look like the heart when rating someone friendly on facepunch (icon16/heart.png), but when I change the “gui/silkicons/heart” to “icon16/heart.png” it just goes a black and purple textured box… We’re really confused about this as the icons work fine for everything else, we have them working fine for the scoreboard and f4 menu etc…
The problem is the same for the Armour, salary and wallet etc too…

Please note, this is our first hud.

You need to add the png to the resources which makes you download it when you join.

It’s [lua]icon16/heart.png[/lua]

No you don’t.

All Garry’s Mod clients come with silkicons, but they are NOT in the gui/silkicons/ directory. They are in the icon16 directory.

Here’s an example:

[lua]local _material = Material( “icon16/heart.png” );
hook.Add(“HUDPaint”, “MyHudName123”, function( )
local health = 100;
local _x1 = 10; local _y1 = ScrH( ) - 35;
local _x2 = 10 + health; local _y2 = ScrH( ) - 20;
surface.SetMaterial( _material );
surface.DrawTexturedArea( _x1, _y1, _x2, _y2, 16, 16 )
end );[/lua]

Wow:

Beat me by 2 minutes :slight_smile:

Thing is… I said what happens when I try icon16/heart.png…

What about [lua]Material(“icon16/heart.png”)[/lua]

That’s why I provided an example, my example shows Material usage :slight_smile:

Texture ID doesn’t work well with PNGs has been my past experience.

Testing it right now, ill provide results in a bit