Jump to content

click GUI


dawid4157

Recommended Posts

Hi,

I have a problem with click in GUI.

I have this code:

function firstGUI(player)  
X_button_Cancel = 0.6  
Y_button_Cancel = 0.7  
Width_button_Cancel = 0.25  
Height_button_Cancel = 0.2  
btnCancel = guiCreateButton(X_button_Cancel, Y_button_Cancel, Width_button_Cancel, Height_button_Cancel, "Cancel", true, register)  
guiWindowSetSizable(register, false)  
guiSetVisible ( register, true )  
showCursor(true)  
  
  
addEventHandler("onClientGUIClick", btnCancel, zamknijgui)  
end  
addCommandHandler("gui", firstGUI) 

and this code:

function zamknijgui()  
outputChatBox("Zamknąłeś GUI")  
end 

Why if I click button nothing happens. Why?

Link to comment
  
function firstGUI(player) 
X_button_Cancel = 0.6 
Y_button_Cancel = 0.7 
Width_button_Cancel = 0.25 
Height_button_Cancel = 0.2 
btnCancel = guiCreateButton(X_button_Cancel, Y_button_Cancel, Width_button_Cancel, Height_button_Cancel, "Cancel", true, register) 
guiWindowSetSizable(register, false) 
guiSetVisible ( register, true ) 
showCursor(true) 
  
  
addEventHandler("onClientGUIClick", btnCancel, zamknijgui, false) 
end 
addCommandHandler("gui", firstGUI) 
  

Link to comment

Yes, register is defined:

local X_okienko_GUI = 300 
        local Y_okienko_GUI = 250 
        local Width_okienko_GUI = 360 
        local Height_okienko_GUI = 220 
        register = guiCreateWindow(X_okienko_GUI, Y_okienko_GUI, Width_okienko_GUI, Height_okienko_GUI, "Panel rejestracji", false) 

Edited by Guest
Link to comment

Maybe I show all code:

function firstGUI(player) 
        --******************************** REGISTER WINDOW 
        local X_okienko_GUI = 300 
        local Y_okienko_GUI = 250 
        local Width_okienko_GUI = 360 
        local Height_okienko_GUI = 220 
        register = guiCreateWindow(X_okienko_GUI, Y_okienko_GUI, Width_okienko_GUI, Height_okienko_GUI, "Panel rejestracji", false) 
        --******************************** LABEL USERNAME 
        X_Label1 = 0.0825 
        Y_Label1 = 0.2 
        Width_Label1 = 0.25 
        Height_Label1 = 0.25 
        guiCreateLabel(X_Label1, Y_Label1, Width_Label1, Height_Label1, "Enter username:", true, register) 
        --******************************** LABEL PASSWORD  
        X_Label2 = 0.0825 
        Y_Label2 = 0.5 
        Width_Label2 = 0.25 
        Height_Label2 = 0.25 
        guiCreateLabel(X_Label2, Y_Label2, Width_Label2, Height_Label2, "Enter password:", true, register) 
        --******************************** ENTER USERNAME 
        X_Pole_User = 0.415 
        Y_Pole_User = 0.17 
        Width_Pole_User = 0.5 
        Height_Pole_User = 0.15 
        pole_User = guiCreateEdit(X_Pole_User, Y_Pole_User, Width_Pole_User, Height_Pole_User, "", true, register) 
        --******************************** ENTER PASSWORD 
        X_Pole_Pass = 0.415 
        Y_Pole_Pass = 0.47 
        Width_Pole_Pass = 0.5 
        Height_Pole_Pass = 0.15 
        pole_Pass = guiCreateEdit(X_Pole_Pass, Y_Pole_Pass, Width_Pole_Pass, Height_Pole_Pass, "", true, register) 
        --******************************** BUTTON REGISTER 
        X_button_Reg = 0.2 
        Y_button_Reg = 0.7 
        Width_button_Reg = 0.25 
        Height_button_Reg = 0.2 
        btnRegister = guiCreateButton(X_button_Reg, Y_button_Reg, Width_button_Reg, Height_button_Reg, "Register", true, register) 
        --******************************** BUTTON CANCEL 
        X_button_Cancel = 0.6 
        Y_button_Cancel = 0.7 
        Width_button_Cancel = 0.25 
        Height_button_Cancel = 0.2 
        btnCancel = guiCreateButton(X_button_Cancel, Y_button_Cancel, Width_button_Cancel, Height_button_Cancel, "Cancel", true, register) 
        --******************************** END 
        guiWindowSetSizable(register, false) 
        guiSetVisible ( register, true ) 
        showCursor(true) -- pokazanie kursora 
  
        [[--if btnCancel~=nil then 
            outputChatBox("Canceled operation...") 
        end --]] 
        addEventHandler("onClientGUIClick", btnCancel, zamknijgui, false) 
end 
  
addCommandHandler("gui", firstGUI) 
  
-- BUTTON CLICK EVENT  
function zamknijgui() 
outputChatBox("Zamknąłeś GUI") 
end 

Link to comment
[[--if btnCancel~=nil then 
            outputChatBox("Canceled operation...") 
        end --]] 

Change [[-- to --[[ and --]] to ]]

[[ means you are entering a string until you close it again with ]]

--[[ until ]] means that part is unreadable by the script.

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