Hey, I'm looking to create a HUD with my own shapes/textures, is this possible?
I want to make a heart in the bottom left of the screen that starts a really bright red when you have 100 hp, and increases in transparency the lower your HP is, until you hit 0 where it is invisible.
What code can i use for this? If i make the heart shape, how do i import it and incorporate it in my HUD?
ALSO: How can i make it so a random command is fired from a table of commands?
im not to great with huds but with the command, create a table of the commands then use table
[b][url=http://wiki.garrysmod.com/?title=Table.Random]Table.Random [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
-snip-
drawtexturedrect
You have to convert your heart image to a vtf and matching vmt with a program like VTFEdit.
Then use something like this:
[lua]
local hearttexture = surface.GetTextureID("path/to/your/texture")
hook.Add("HUDPaint", "DrawHealthHeart", function()
local healthalpha = math.Clamp(255 * (LocalPlayer():Health() * .01), 0, 255)
surface.SetDrawColor(255,255,255, healthalpha)
surface.SetTexture(hearttexture)
surface.DrawTexturedRect(posx, posy, width, height) --Change these values for where you want it
--And how large you want the heart to be
end[/lua]
Sorry, you need to Log In to post a reply to this thread.