megaman54 Posted December 5, 2009 Share Posted December 5, 2009 Hello! I made this today and i want to know what is wrong with it. It is workin when i type /setskin it loads the GUI all good but when i try to close it via the close button it wont close. So here is the code: function windowClose() guiSetvisible(skinGui, false) guiSetInputEnabled(skinGui, false) end addEventHandler ( "onClientGUIClick", closeButton, windowClose, false ) that is only the part of code what closes the gui but it is not working. Tell me what is wrong. Link to comment
robhol Posted December 5, 2009 Share Posted December 5, 2009 Function and variable names are case sensitive. It's "Visible", not "visible", "VISIBLE" or "vISiBlE". Link to comment
megaman54 Posted December 5, 2009 Author Share Posted December 5, 2009 Function and variable names are case sensitive. It's "Visible", not "visible", "VISIBLE" or "vISiBlE". Still not working Link to comment
CallumD Posted December 6, 2009 Share Posted December 6, 2009 try adding the following after the close button code (change "butttonNameHere" and "functionNameHere" of course): addEventHandler ( "onClientGUIClick", buttonNameHere, functionNameHere, false, false ) then make a function something like this: function functionNameHere () guiSetVisible ( skinGui, false ) guiSetInputEnabled ( skinGui, false ) end Link to comment
50p Posted December 6, 2009 Share Posted December 6, 2009 The reason why it doesn't work is probably this: https://forum.multitheftauto.com/viewtop ... 00#p289183 Link to comment
subenji99 Posted December 6, 2009 Share Posted December 6, 2009 Another case of learning to debug would prevent a stupid question. You'll find debugscript reports an error on your addEventHandler line that closeButton is a "bad element pointer". (The message may be different, but the cause is the element doesn't exist.) As 50p explains, code is executed sequentially when the resource first starts - as this happens, functions are loaded into memory and can then be accessed (why you would normally put a handler line below it's called function) but lines not in functions are executed immediately. (adding the event handler in this case) Functions don't execute until they are called, either by a line outside a function or by event handlers etc. The assumption here is that you have a function that creates your GUI window - so as the script loads, your createGUI function is loaded and ready to execute, but hasn't been called yet. So your GUI doesn't exist just yet, and any elements created there also don't exist yet and cannot be accessed. Solution is simple, and there are 2 methods to go about it. Move your addEventHandler line that attaches to closeButton into the createGUI function AFTER closeButton is created (remember that functions generally get executed after loading the script so your windowClose function is accessible) or Don't create your GUI inside a function - it only has to be created once after all, you can hide it (with guiSetVisible) instantly, and then all your GUI elements will be accessible anywhere. Link to comment
megaman54 Posted December 12, 2009 Author Share Posted December 12, 2009 YAY! The close button is working as it should work. But new peoblem is that after i close the window with the button the cursor keeps showing and i can just reconnect to get it off. So do i need to use: guiSetInputEnabled(skinGui, false) or something lese? Link to comment
robhol Posted December 12, 2009 Share Posted December 12, 2009 YAY! The close button is working as it should work. But new peoblem is that after i close the window with the button the cursor keeps showing and i can just reconnect to get it off. So do i need to use: guiSetInputEnabled(skinGui, false) or something lese? It only has one boolean parameter - in this case false. Please learn to use the wiki? Link to comment
megaman54 Posted December 12, 2009 Author Share Posted December 12, 2009 Sorry! I was so stupid that i dint notice that but thanks anyways! Its working now! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now