dawid4157 Posted August 7, 2014 Posted August 7, 2014 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?
Anubhav Posted August 7, 2014 Posted August 7, 2014 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)
dawid4157 Posted August 7, 2014 Author Posted August 7, 2014 Sorry continue unchanged. Maybe other idea?
TAPL Posted August 8, 2014 Posted August 8, 2014 Make sure you have both code in client side and by the way addCommandHandler client side don't have player parameter.
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 Code is in client side, but click do not work fine. Can someone perform example code for me? Please.
Et-win Posted August 8, 2014 Posted August 8, 2014 Is 'register' located? Also check command: /debugscript 3 and if there comes an error after starting the resource/using the command, then post those errors here.
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 [2014-08-08 12:36:51] debugscript: Incorrect client type for this command What is this?
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 When I use command in game nothing happens. Is only this statement: [2014-08-08 14:30:46] DENIED: Denied 'dawid4157' access to command 'debugscript'
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 I am logeed in as admin. Command not work.
Et-win Posted August 8, 2014 Posted August 8, 2014 I doubt it, because otherwise it would work. You need Admin and not Moderator... Otherwise I don't know. And again: is 'register' defined?
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 (edited) 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 August 8, 2014 by Guest
TAPL Posted August 8, 2014 Posted August 8, 2014 Post all the code and the meta and please use Lua tag not 'Code'.
dawid4157 Posted August 8, 2014 Author Posted August 8, 2014 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
Et-win Posted August 8, 2014 Posted August 8, 2014 [[--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.
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