nilsathp Posted December 29, 2011 Share Posted December 29, 2011 (edited) I have a little but annoying problem with my script. It´s my first GUI script. The script should close the window after i´ve pressed the button close. The cursor is not visible anymore and I can play the game, but the window is still in the middle of my screen and it isn´t closing, although I´ve written the code in my script: guiSetVisible(gui, false) Here is the whole script: (You can find the problem at the end of the script) local gui = {} function GUI() gui._placeHolders = {} local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 531, 452 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 gui["_root"] = guiCreateWindow(left, top, windowWidth, windowHeight, "Spawnpunkt - Login", false) guiWindowSetSizable(gui["_root"], false) gui["pushButton"] = guiCreateButton(80, 283, 371, 28, "Airport Los Santos", false, gui["_root"]) if on_pushButton_clicked then addEventHandler("onClientGUIClick", gui["pushButton"], on_pushButton_clicked, false) end gui["pushButton_3"] = guiCreateButton(80, 167, 371, 28, "Airport San Fierro", false, gui["_root"]) if on_pushButton_3_clicked then addEventHandler("onClientGUIClick", gui["pushButton_3"], on_pushButton_3_clicked, false) end gui["pushButton_4"] = guiCreateButton(80, 109, 371, 28, "CJ´s Hood", false, gui["_root"]) if on_pushButton_4_clicked then addEventHandler("onClientGUIClick", gui["pushButton_4"], on_pushButton_4_clicked, false) end gui["pushButton_2"] = guiCreateButton(80, 225, 371, 28, "Airport Las Venturas", false, gui["_root"]) if on_pushButton_2_clicked then addEventHandler("onClientGUIClick", gui["pushButton_2"], on_pushButton_2_clicked, false) end gui["pushButton_5"] = guiCreateButton(420, 425, 101, 21, "login", false, gui["_root"]) if on_pushButton_5_clicked then addEventHandler("onClientGUIClick", gui["pushButton_5"], on_pushButton_5_clicked, false) end gui["pushButton_6"] = guiCreateButton(80, 355, 121, 23, "OK", false, gui["_root"]) if on_pushButton_6_clicked then addEventHandler("onClientGUIClick", gui["pushButton_6"], on_pushButton_6_clicked, false) end return gui, windowWidth, windowHeight end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () GUI() guiSetVisible(gui, true) showCursor(true) guiSetInputEnabled(true) end ) function on_pushButton_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here triggerServerEvent("spawnLosSantos", getRootElement(), username, password) end function on_pushButton_3_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here triggerServerEvent("spawnSanFierro", getRootElement(), username, password) end function on_pushButton_4_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here triggerServerEvent("spawnCJ", getRootElement(), username, password) end function on_pushButton_2_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here triggerServerEvent("spawnVenturas", getRootElement(), username, password) end function on_pushButton_5_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here triggerServerEvent("doLogin", getRootElement(), username, password) end function on_pushButton_6_clicked(button, state, absoluteX, absoluteY) if (button ~= "left") or (state ~= "up") then return end --TODO: Implement your button click handler here function hideGUI() guiSetVisible(gui, false) showCursor(false) guiSetInputEnabled(false) end addEventHandler ( "onClientGUIClick", gui["pushButton_6"], hideGUI, false ) end I don´t get any warnings or errors... I thank you in advance, nilsathp Edited December 30, 2011 by Guest Link to comment
Xeno Posted December 29, 2011 Share Posted December 29, 2011 This ("_root") thing annoys me, I'm not sure how to solve it but try this: guiSetVisible(gui["_root"], false) Link to comment
nilsathp Posted December 29, 2011 Author Share Posted December 29, 2011 Yes, thank you very much, this is the solution! 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