1. Post #1

    November 2009
    474 Posts
    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
    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?

  2. Post #2
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    local myCVar = CreateClientConVar("blabla", 0, true, true)
    print(myCVar:GetBool())
    

    Just use this method.
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Agree Agree x 1Disagree Disagree x 1 (list)

  3. Post #3

    November 2009
    474 Posts
    local myCVar = CreateClientConVar("blabla", 0, true, true)
    print(myCVar:GetBool())
    

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

  4. Post #4
    frosty802's Avatar
    April 2009
    445 Posts
    Code:
    if myCVar then
    --draw word box
    end

  5. Post #5

    November 2009
    474 Posts
    Code:
    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?

  6. Post #6
    The way with the slightest resistance!
    |Royal|'s Avatar
    May 2011
    84 Posts
    
    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)
    

  7. Post #7
    Dragon Dildoes
    Dennab
    April 2009
    4,432 Posts
    
    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)
    
    Afaik using GetBool on the convar object it faster but this works too.
    Reply With Quote Edit / Delete Reply Windows 7 Germany Show Events Lua Helper Lua Helper x 1 (list)

  8. Post #8

    November 2009
    474 Posts
    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.

  9. Post #9
    Gold Member

    June 2009
    340 Posts
    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.
    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)
    
    should work perfectly. Just do script_enabled 1/0 in console.