Jump to content

Problem?


glowdemon1

Recommended Posts

    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 ? :(

Link to comment

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 

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