enzopaul4 Posted December 20, 2016 Share Posted December 20, 2016 local sx, sy = guiGetScreenSize ( ) function centerGUI ( guiElement ) local width, height = guiGetSize ( guiElement, false ) local x, y = ( sx / 2 - width / 2 ), ( sy / 2 - height / 2 ) guiSetPosition ( guiElement, x, y, false ) end GUIEditor = { tab = {}, staticimage = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(423, 331, 523, 367, "", false) guiWindowSetSizable(GUIEditor.window[1], false) centerGUI(GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1],false) GUIEditor.tabpanel[1] = guiCreateTabPanel(11, 109, 502, 241, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(27, 31, 63, 15, "Username", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(100, 30, 352, 26, "", false, GUIEditor.tab[1]) GUIEditor.edit[2] = guiCreateEdit(97, 74, 355, 24, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(314, 152, 153, 42, "Login", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1]) GUIEditor.label[2] = guiCreateLabel(16, 26, 76, 15, "Username : ", false, GUIEditor.tab[2]) GUIEditor.label[3] = guiCreateLabel(16, 51, 60, 15, "Password : ", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(18, 80, 42, 15, "Email : ", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(311, 168, 147, 39, "Register", false, GUIEditor.tab[2]) GUIEditor.edit[4] = guiCreateEdit(90, 24, 388, 27, "x", false, GUIEditor.tab[2]) GUIEditor.edit[5] = guiCreateEdit(90, 52, 388, 28, "y", false, GUIEditor.tab[2]) GUIEditor.edit[6] = guiCreateEdit(85, 79, 393, 26, "z", false, GUIEditor.tab[2]) addEvent("showHide",true) function showHide() if guiGetVisible(GUIEditor.window[1]) == true then guiSetVisible(GUIEditor.window[1],false) showCursor(false) elseif guiGetVisible(GUIEditor.window[1]) == false then guiSetVisible(GUIEditor.window[1],true) showCursor(true) end end addEventHandler("showHide",getLocalPlayer(),showHide) showHide() function buttonClick() if source == GUIEditor.button[2] then local username = guiGetText(GUIEditor.edit[4]) local password = guiGetText(GUIEditor.edit[5]) local email = guiGetText(GUIEditor.edit[6]) triggerServerEvent("registerRequest",getLocalPlayer(),getLocalPlayer(),username,password,email) elseif source == GUIEditor.button[1] then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) triggerServerEvent("loginRequest",getLocalPlayer(),getLocalPlayer(),username,password) end end addEventHandler("onClientGUIClick",GUIEditor.window[1],buttonClick) if i press register or login it is doesn't working , i have database upload on phpmyadmin , it is working really good , but it is a problem with this buttons Link to comment
idarrr Posted December 20, 2016 Share Posted December 20, 2016 (edited) on line 70, source is not the button, but the window (correct me if im wrong). so it will never get passed on if source == GUIEditor.button[2] then addEventHandler("onClientGUIClick",GUIEditor.window[1],buttonClick) should be like this addEventHandler("onClientGUIClick",GUIEditor.button[2],buttonClick) You may need to add another event to handle another button. Full Code: local sx, sy = guiGetScreenSize ( ) function centerGUI ( guiElement ) local width, height = guiGetSize ( guiElement, false ) local x, y = ( sx / 2 - width / 2 ), ( sy / 2 - height / 2 ) guiSetPosition ( guiElement, x, y, false ) end GUIEditor = { tab = {}, staticimage = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {} } GUIEditor.window[1] = guiCreateWindow(423, 331, 523, 367, "", false) guiWindowSetSizable(GUIEditor.window[1], false) centerGUI(GUIEditor.window[1]) guiSetVisible(GUIEditor.window[1],false) GUIEditor.tabpanel[1] = guiCreateTabPanel(11, 109, 502, 241, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Login", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(27, 31, 63, 15, "Username", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(100, 30, 352, 26, "", false, GUIEditor.tab[1]) GUIEditor.edit[2] = guiCreateEdit(97, 74, 355, 24, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(314, 152, 153, 42, "Login", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Register", GUIEditor.tabpanel[1]) GUIEditor.label[2] = guiCreateLabel(16, 26, 76, 15, "Username : ", false, GUIEditor.tab[2]) GUIEditor.label[3] = guiCreateLabel(16, 51, 60, 15, "Password : ", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(18, 80, 42, 15, "Email : ", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(311, 168, 147, 39, "Register", false, GUIEditor.tab[2]) GUIEditor.edit[4] = guiCreateEdit(90, 24, 388, 27, "x", false, GUIEditor.tab[2]) GUIEditor.edit[5] = guiCreateEdit(90, 52, 388, 28, "y", false, GUIEditor.tab[2]) GUIEditor.edit[6] = guiCreateEdit(85, 79, 393, 26, "z", false, GUIEditor.tab[2]) addEvent("showHide",true) function showHide() if guiGetVisible(GUIEditor.window[1]) == true then guiSetVisible(GUIEditor.window[1],false) showCursor(false) elseif guiGetVisible(GUIEditor.window[1]) == false then guiSetVisible(GUIEditor.window[1],true) showCursor(true) end end addEventHandler("showHide",getLocalPlayer(),showHide) showHide() function buttonClick1() if source == GUIEditor.button[1] then local username = guiGetText(GUIEditor.edit[1]) local password = guiGetText(GUIEditor.edit[2]) triggerServerEvent("loginRequest",getLocalPlayer(),getLocalPlayer(),username,password) end end addEventHandler("onClientGUIClick",GUIEditor.button[1],buttonClick1) function buttonClick2() if source == GUIEditor.button[2] then local username = guiGetText(GUIEditor.edit[4]) local password = guiGetText(GUIEditor.edit[5]) local email = guiGetText(GUIEditor.edit[6]) triggerServerEvent("registerRequest",getLocalPlayer(),getLocalPlayer(),username,password,email) end end addEventHandler("onClientGUIClick",GUIEditor.button[2],buttonClick2) Edited December 20, 2016 by idarrr Edit for full code Link to comment
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