Jump to content

GUI Problem.


NextGenRP

Recommended Posts

Hey im trying to close a GUI,

  
function GUIFunction() 
-- other gui elements are here that work fine, Including a button that works fine too. 
closeButtonn = guiCreateButton(sWidth-697,sHeight-425,sWidth-981,sHeight-744,"Close",false,registerWindow) 
addEventHandler("onClientGUIClick", closeButtonn, closeRegiWindow, false) 
end 
  
function closeRegiWindow() 
destroyElement(registerWindow) --I want to destroy the window, If the player clicks on the button that opened it it will run the GUIFunction again. 
end 
  

It just acts as if im not clicking the button when i am and there is no errors in the debug.

Edited by Guest
Link to comment
closeButtonn = guiCreateButton(sWidth-697,sHeight-425,sWidth-981,sHeight-744,"Close",false,registerWindow) 
  
function closeRegisterrWindow() 
    guiSetVisible(registerWindow, false) 
end 
addEventHandler("onClientGUIClick", closeButtonn, closeRegisterrWindow) 

I think...

Link to comment

The button isn't created until the GUIFunction creates the GUI, So i can't add an event handler to a button that doesn't exist? Im not sure but i don't think so, I see you put the handler under the function i want to use i moved the function above the GUIFunction and it seems to work thanks :D

Link to comment

I wouldn't suggest doing this, I would suggest using:

function randomFunction(button) 
    if (button) ~= "left" then return end 
    if (source == closeButtonn) then 
        guiSetVisible( yourGUIElement, false) 
    elseif ( source == someGUIElement ) then  
       --something 
    end 
end 
addEventHandler("onClientGUIClick", resourceRoot,  randomFunction, true) 

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...