Avoiding rendering errors

Hai, currently I’m making a new HUD for a modification of DarkRP.
It seems like when I make use of surface.DrawTexturedRect() **[Surface.DrawTexturedRect

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Surface.DrawTexturedRect)** then it gets very sensitive about player movement & if the HUD is moving but also about lightning(flashlight) which is pretty bad because this is for battery time.

Is there anyway to override how it’s supposed to be lit?
Or anything else there could fix this.

[LUA]

 -- FlashLight, Note that the only way to regain energy would be to purchase a battery entity.
 if LocalPlayer().DarkRPVars.Battery ~= 100 then
 surface.SetDrawColor(45, 45, 145, 100)
 local Texture = surface.GetTextureID( "vgui/Unarmed_Infantry/bluewaveslarge")
 local mat = Material("vgui/Unarmed_Infantry/bluewaveslarge")
 local TextureX = ScrW()/2 - 95
 local TextureY = ScrH() / 2 + 400
 
 surface.SetTexture(Texture)
 surface.SetMaterial(mat)
 surface.DrawTexturedRect( tonumber(ScrW())/2 - 95, ScrH() / 2 + 400, tonumber(LocalPlayer().DarkRPVars.Battery) * 2, 30 )

 surface.SetDrawColor(0, 0, 0, 255)
 surface.DrawRect( TextureX, TextureY - 5, 200, 7 ) -- Upperbar
 
 surface.SetDrawColor(120, 0, 0, 100)
 surface.DrawRect( TextureX, TextureY, 200, 35 ) -- bacground.
 
 surface.SetDrawColor(0, 0, 0, 255)
 surface.DrawRect(TextureX, TextureY + 30, 200, 50) -- Under bar.
 
 surface.SetDrawColor(0, 0, 0, 255)
 surface.DrawRect(TextureX, TextureY, 5, 50) -- left bar.
 
 surface.SetDrawColor(0, 0, 0, 255)
 surface.DrawRect(TextureX + 200, TextureY - 5, 5, 55) -- right bar.

[/LUA]

First of all you don’t need SetTexture when you’re using SetMaterial.
To avoid the lighting errors replace line 5 with
[lua]
local mat = CreateMaterial(“whatever_name”,“UnlitGeneric”,{["$basetexture"] = “vgui/Unarmed_Infantry/bluewaveslarge”})
[/lua]

That worked out great, thanks.