glowdemon1 Posted August 22, 2013 Posted August 22, 2013 function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then vendingWindow = guiCreateWindow(0.375,0.375,0.25,0.25,"Vending machine by freshhh", true) cancelButton = guiCreateButton(0.7,0.1,0.2,0.1,"Cancel", true) buyButton = guiCreateButton(0.9,0.1,0.2,0.1,"Purchase", true) end end function shutDownGUI(button, state) if button == "left" and state == "up" then guiSetVisible (vendingWindow, not guiGetVisible ( vendingWindow ) ) showCursor(false) end end addEventHandler("onClientClick", getRootElement(), onMachineClick) addEventHandler("onClientGUIClick", cancelButton, shutDownGUI, false) Whenever I click the cancel button, the GUI doesn't go away. I'm new to GUI's, so any help ? MySQL based MP3 System - unique radio stations My mappings
TAPL Posted August 22, 2013 Posted August 22, 2013 You was add the event before the button created. function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then vendingWindow = guiCreateWindow(0.375,0.375,0.25,0.25,"Vending machine by freshhh", true) cancelButton = guiCreateButton(0.7,0.1,0.2,0.1,"Cancel", true) addEventHandler("onClientGUIClick", cancelButton, shutDownGUI, false) buyButton = guiCreateButton(0.9,0.1,0.2,0.1,"Purchase", true) end end addEventHandler("onClientClick", getRootElement(), onMachineClick) function shutDownGUI(button, state) if button == "left" and state == "up" then guiSetVisible (vendingWindow, not guiGetVisible ( vendingWindow ) ) showCursor(false) end end
glowdemon1 Posted August 22, 2013 Author Posted August 22, 2013 Oooh, thanks alot. MySQL based MP3 System - unique radio stations My mappings
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