Question regarding surface.DrawPoly

As the title suggests, i have a question regarding surface.DrawPoly

First off,



tex = surface.GetTextureID( "vgui/white" )
surface.SetDrawColor( 0, 0, 0, 255 )
tbl = { {}, {}, {}, {} }
tbl[1]["x"] = ScrW() / 4 + 30
tbl[1]["y"] = ScrH() - 4
tbl[2]["x"] = ScrW() / 4 - 335
tbl[2]["y"] = ScrH() - 4
tbl[3]["x"] = ScrW() / 4 - 335
tbl[3]["y"] = ScrH() - 44
tbl[4]["x"] = ScrW() / 4 - 10
tbl[4]["y"] = ScrH() - 44
surface.SetTexture( tex )
surface.DrawPoly( tbl )

tex = surface.GetTextureID( "vgui/white" )
surface.SetDrawColor( 255, 0, 0, 255 )
tbl = { {}, {}, {}, {} }
tbl[1]["x"] = ScrW() / 4 + 25
tbl[1]["y"] = ScrH() - 6
tbl[2]["x"] = ScrW() / 4 - 333
tbl[2]["y"] = ScrH() - 6
tbl[3]["x"] = ScrW() / 4 - 333
tbl[3]["y"] = ScrH() - 42
tbl[4]["x"] = ScrW() / 4 - 10
tbl[4]["y"] = ScrH() - 42
surface.SetTexture( tex )
surface.DrawPoly( tbl )
draw.SimpleText( "100%", "HealthFont", 43, ScrH() - 40, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )


Every time I have this actually loaded into GMod local server for testing, it tends to use up my PC’s memory, or just crashes gmod and makes my Pc slow overall, how would I fix this?

I was also wondering how I would go about making a health bar with something like this? Thanks beforehand for the help.

Create the table outside of the drawing hook.

[editline]5th June 2014[/editline]

And the texture too.

Wow, such a rookie mistake that fixed the lag/pc memory usage altogether, how would I go about making the red part of the bar an actual health bar? Thanks again for the help.

You will have to alter the table to your needs. And this board is not for Lua scripting help.

http://facepunch.com/forums/65

Oh, i’m very sorry I didn’t think about developer discussion, thanks for directing me to the correct place.