Hello...
In a HUD my friend made (Buu342), we have a problem. Above in the hud, is icon16/heart.png to display VIP status's, which works fine,
however, when we add that to the health bar, it shows up as black and purple...
This is the health code...
[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("icon16/heart.png"))
surface.DrawTexturedRect(Main -15-50,ScrH() - 38,16,16)
[/code]
this is the code where icon16/heart.png works...
[code]FGHUD.Ranks["vip"] = "icon16/heart.png"[/code]
How come it works in one but not the other?
Pretty sure you have to use Material("material") for PNGs, correct me if I'm wrong.
You're supposed to do this for PNGs:
[lua]
local HeartImage = Material("icon16/heart.png")
hook.Add("HUDPaint","Whatever",function()
surface.SetMaterial(HeartImage)
surface.DrawTexturedRect(x, y, w, h)
end)
[/lua]
[QUOTE=arcaneex;42936888]Pretty sure you have to use Material("material") for PNGs, correct me if I'm wrong.[/QUOTE]
I'm pretty sure you only need to use the Material function if you want to add parameters to the png. Although I've only used PNGs with derma, but there are multiple instances in the garrysmod lua source where .pngs are used without anything else, there's a lot in TTT.
Sorry, you need to Log In to post a reply to this thread.