Danz Posted December 20, 2014 Share Posted December 20, 2014 Well i have a problem with my GUI, let me get into details, i'll try to explain this as best as i can because i kinda a newb at scripting, anyway. function createStatsGUI() mainWindow = guiCreateWindow(463, 151, 367, 501, "Player Statistics", false) playerGrid = guiCreateGridList(9, 26, 177, 465, false, mainWindow) closeBtn = guiCreateButton(244, 444, 113, 47, "Close", false, mainWindow) end addEventHandler("onClientResourceStart", resourceRoot, createStatsGUI) function toggleStatsGUI() guiSetVisible (mainWindow, not guiGetVisible (mainWindow)) showCursor (not isCursorShowing()) end bindKey("F2", "down", toggleStatsGUI) From the code above i do not understand what is wrong. Let me say, When the resource starts, my GUI appears, it's bound to F2, when you press F2, the GUI disappears and my Cursor appears, well i want to make it when the resource starts, it doesn't show the GUI, it should show it when i press F2, and my cursor appear when i press F2 with the GUI, any help would be nice, and thank you. Link to comment
Bonsai Posted December 20, 2014 Share Posted December 20, 2014 You only forgot to set the visibilty to false after creating it. Then it should do. Link to comment
Danz Posted December 20, 2014 Author Share Posted December 20, 2014 Could you show me the "Fixed" code of my given code? Because i don't quite understand what i should change... Link to comment
Dealman Posted December 20, 2014 Share Posted December 20, 2014 It's rather simple; 1. When your resource is started, it creates the GUI. By default, the window is visible after creation. 2. When you press F2, it will toggle the cursor, and set the visible state of the window to the opposite. Since it's already visible(true), you'll be setting it to not visible(false). The fix is simple; mainWindow = guiCreateWindow(463, 151, 367, 501, "Player Statistics", false) guiSetVisible(mainWindow, false) By doing this, the state will be false - thus when you first press F2, it will change to true - making the window visible. Link to comment
Danz Posted December 20, 2014 Author Share Posted December 20, 2014 Thank you Dealman, this worked perfectly , any moderator can /lock this. Thanks again! 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