Jump to content

I do not understand this...


Danz

Recommended Posts

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

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

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