krgunner Posted December 29, 2008 Share Posted December 29, 2008 hi i dont know why but i cant make this gui disappear function loginWindow ( ) loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui) showCursor ( true ) function guiExit ( button ) guiSetVisible (loginGui, false ) showCursor ( false ) outputChatBox ( "test" ) end addEventHandler ( "onClientGUIClick", CloseGui, guiExit ) addCommandHandler ( "test", loginWindow ) can ayone help? Link to comment
XetaQuake Posted December 29, 2008 Share Posted December 29, 2008 You have a second function inside the first function - but only one end Try this: function loginWindow ( ) loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui) showCursor ( true ) function guiExit ( button ) guiSetVisible (loginGui, false ) showCursor ( false ) outputChatBox ( "test" ) end end Or better, try this: function loginWindow ( ) loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui) showCursor ( true ) end function guiExit ( button ) guiSetVisible (loginGui, false ) showCursor ( false ) outputChatBox ( "test" ) end Link to comment
[DKR]silverfang Posted December 30, 2008 Share Posted December 30, 2008 function loginWindow ( ) loginGui = guiCreateWindow ( 300, 250, 500, 350, "test gui", false ) CloseGui = guiCreateButton( 0.60, 0.90, 0.30, 0.05, "close", true, loginGui) showCursor ( true ) addEventHandler ( "onClientGUIClick", CloseGui, guiExit ) end function guiExit ( button ) guiSetVisible (loginGui, false ) showCursor ( false ) outputChatBox ( "test" ) end addCommandHandler ( "test", loginWindow ) Personally I add the Event Handlers for any GUI Element in the function that it was created, as if it's done outside of a function it's loaded with the resource and sometimes (such as this case) the GUI element hasn't been created yet... 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