Jump to content

guiSetVisible not working


hackermagus

Recommended Posts

I made a script

  function drawPanel()
      dxDrawRectangle(406.0,277.0,650.0,235.0,tocolor(0,0,0,175),false)
      dxDrawLine(447.0,318.0,1005.0,318.0,tocolor(255,255,255,255),1.0,false)
      dxDrawText("Rádió",456.0,285.0,642.0,319.0,tocolor(0,0,0,255),1.0,"pricedown","left","top",false,false,false)
      dxDrawText("Rádió",451.0,289.0,637.0,323.0,tocolor(255,255,0,170),1.0,"pricedown","left","top",false,false,false)
  end

  function openandclose()
if removeEventHandler("onClientRender", root, drawPanel) then
    removEventHandler("onClientRender", root, drawPanel)
    	guiSetVisible(prev, false)
    	guiSetVisible(nxt, false)
    else
    addEventHandler("onClientRender", root, drawPanel)
    	guiSetVisible(prev, true)
    	guiSetVisible(nxt, true)
    end
  end
bindKey("r","down",openandclose)

prev = guiCreateButton(453, 335, 35, 35, "<", false)
guiSetFont (prev, "default-bold-small")

nxt = guiCreateButton(999, 335, 35, 35, ">", false)
guiSetFont (nxt, "default-bold-small")

And the buttons show up everytime if the visible or not..

The debugscript 3 says: "Attempt to call global'removeEventHandler' (a nil value)"

How to solve that?

Link to comment

Line 10 has a typo - it's removeEventHandler not removEventHandler. Besides, that line is unnecessary. The if-line above it already calls that function and its side-effects are executed (i.e. handler gets removed from the function or a false is returned because it's not attached anyway, so calling it again won't work - it'll either be removed or it wasn't attached in the first place)

Edited by MrTasty
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...