Helmet Overlay- Doesn't Work

I’ve been trying to make a helmet overlay with hud, as my first proper LUA code, but I’ve already hit problems:
[lua]local iScreenWidth = surface.ScreenWidth()
local iScreenHeight = surface.ScreenHeight()
local HelmetTex = surface.GetTextureID(“Helmet/Helmet”)
local function drawHelmetTexture()
surface.SetTexture(HelmetTex)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(0,0,iScreenWidth,iScreenHeight)
end

concommand.Add( “HelmetOn”, drawHelmetTexture )
[/lua]
There are no actual errors in the script according to the game, and the ConCommand shows up, but when I use it, nothing happens.
Also, how would I go about adding my matirial to the matirial tool.

The drawing needs to be done in a HUDPaint hook, at the moment your code is drawing the texture for one frame only, I would do something like this:

[lua]local iScreenWidth = ScrW()
local iScreenHeight = ScrH()
local HelmetTex = surface.GetTextureID(“Helmet/Helmet”)
local function drawHelmetTexture()
hook.Add( “HUDPaint”, “DrawHelmetOverlay”, function()
surface.SetTexture(HelmetTex)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(0,0,iScreenWidth,iScreenHeight)
end)
end

concommand.Add( “HelmetOn”, drawHelmetTexture )

local function removeHelmetTexture()
hook.Remove( “HUDPaint”, “DrawHelmetOverlay” )
end

concommand.Add( “HelmetOff”, removeHelmetTexture )[/lua]

[lua]
local iScreenWidth = ScrW()
local iScreenHeight = ScrH()
[/lua]

Thanks for the quick reply, at first it didn’t work, then I realised I left the line numbers in lol. Anyway thanks, shoulda noticed the HUDPaint hook, and thanks for sorting the Off command.

[editline]12:03AM[/editline]

Damn, the HelmetOff code isn’t working

Because the hook you are removing is called DrawHealmet…

Lol, thanks. I must be going blind

Oops, small spelling mistake, sorry about that.

Its ok, not your fault