Question about draw.WordBox.

I’m trying to put some simple text in the corner of my screen, but ONLY when a convar is set to 1.

Convar is script_enabled 1/0

Current Code


function PaintScript()
        draw.WordBox( 12, ScrW() - 325, ScrH() - 942, Script Enabled","ScoreboardText",Color(50,50,75,100),Color(0,0,255,255))  
	end
hook.Add("HUDPaint","PaintScript",PaintScript)

How would I make it disappear when the convar is 0, etc?

[lua]
local myCVar = CreateClientConVar(“blabla”, 0, true, true)
print(myCVar:GetBool())
[/lua]

Just use this method.

Already using this, just want to know how to remove the Wordbox after convar is 0


if myCVar then
--draw word box
end

Okay, so if the word box is already drawn, then I change the CVar to zero, How do I remove the wordbox from the screen?

[lua]

CreateClientConVar(“script_enabled”,0,true,false)

function PaintScript()

if(GetConVarNumber(“script_enabled”) == 0 ) then return end
draw.WordBox( 12, ScrW() - 325, ScrH() - 942, Script Enabled",“ScoreboardText”,Color(50,50,75,100),Color(0,0,255,255))

end
hook.Add(“HUDPaint”,“PaintScript”,PaintScript)
[/lua]

Afaik using GetBool on the convar object it faster but this works too.

If I make a seperate timer, use the same ScrW and ScrH, but set the alphas to 0, 0, will this make them void?

You’re missing a quotation in the syntax you provided, it still doesn’t really answer my question of what to do when I want the thing to go away.

In a shell, if the script enabled = 1, then I want to to be painted to the HUD, if its 0, then I want it gone.

It did answer your question.

HUDPaint runs every frame. It’s constantly checking the cvar.
[lua]
local myvar = CreateClientConVar(“script_enabled”, 0, true, true)

function PaintScript()

 if !myvar:GetBool() then return end

 draw.WordBox(12, ScrW() - 325, ScrH() - 942, "Script  Enabled","ScoreboardText",Color(50,50,75,100),Color(0,0,255,255))  

end
hook.Add(“HUDPaint”, “PaintScript”, PaintScript)
[/lua] should work perfectly. Just do script_enabled 1/0 in console.