Wes Posted May 30, 2013 Posted May 30, 2013 So I made a login panel, but it doesn't want to work When I click on the "Bejelentkezés" button it should log me into the account. But it doesnt Here is the source: CLIENTSIDE function clientsubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) guiSetInputEnabled(false) guiSetVisible(showLoginPanel, false) showCursor(false) end end end addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) SERVERSIDE function loginHandler(username, password) local account = getAccount(username, password) if (account ~= false) then if (client) then logIn(client, username, password) spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Üdv ismét," .. client .. "!") end else outputChatBox("Nem megfelelő felhasználónév / jelszó") end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginHandler) Thanks for the help.
Castillo Posted May 30, 2013 Posted May 30, 2013 Change this line: triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) to: triggerServerEvent ( "submitLogin", localPlayer, username, password )
Wes Posted May 30, 2013 Author Posted May 30, 2013 Nope, still doesnt work.. If you post a solution could you explain why do I have to change that? So next time I'll learn from this.
Castillo Posted May 30, 2013 Posted May 30, 2013 Have you added the resource to the acl.xml, group "Admin"?
Wes Posted May 30, 2013 Author Posted May 30, 2013 Bad argument @ addEventHandler [Expected element at argument 2, got nil] This line addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) bejelentkezes is the name of the button.
Castillo Posted May 30, 2013 Posted May 30, 2013 logIn(client, username, password) That line is wrong, logIn function requires an account, not username. logIn(client, account, password)
Wes Posted May 30, 2013 Author Posted May 30, 2013 (edited) Let me check Edited May 30, 2013 by Guest
Wes Posted May 30, 2013 Author Posted May 30, 2013 What edited script? I made it myself, using a tutorial.. This is the GUI setup: UIEditor = { tabpanel = {}, window = {} } function showLoginPanel() GUIEditor.window[1] = guiCreateWindow(457, 348, 603, 277, "MTAProject Bejelentkezés & Regisztráció", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(27, 27, 544, 229, false, GUIEditor.window[1]) tabLogin = guiCreateTab("Bejelentkezés", GUIEditor.tabpanel[1]) username = guiCreateEdit(144, 25, 242, 30, "dsa", false, tabLogin) password = guiCreateEdit(144, 99, 242, 30, "dsa", false, tabLogin) bejelentkezes = guiCreateButton(144, 146, 236, 44, "Bejelentkezés", false, tabLogin) tabRegister = guiCreateTab("Regisztráció", GUIEditor.tabpanel[1]) regusername = guiCreateEdit(144, 25, 242, 30, "da", false, tabRegister) regpassword = guiCreateEdit(144, 99, 242, 30, "da", false, tabRegister) register = guiCreateButton(144, 146, 236, 44, "Regisztráció", false, tabRegister) --Regisztrációnál használatos label regFelhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabRegister) regJelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabRegister) guiSetFont(regFelhasznLabel, "default-bold-small") guiSetFont(regJelszoLabel, "default-bold-small") --Bejelentkezésnél használatos label felhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabLogin) jelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabLogin) guiSetFont(felhasznLabel, "default-bold-small") guiSetFont(jelszoLabel, "default-bold-small") showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", resourceRoot, showLoginPanel) function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitLogin", localPlayer, username, password) guiSetInputEnabled(false) guiSetVisible(showLoginPanel, false) showCursor(false) end end end addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) function loginHandler(username, password) local account = getAccount(username, password) if (account ~= false) then if (client) then logIn(client, account, password) spawnPlayer(client, 1959.55, -1714.46, 10) fadeCamera(client, true) setCameraTarget(client, client) outputChatBox("Üdv ismét," .. client .. "!") end else outputChatBox("Nem megfelelő felhasználónév / jelszó") end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginHandler)
Wes Posted May 30, 2013 Author Posted May 30, 2013 WARNING: RP\c_login.lua:61: Bad Argument @ addEventHandler [Expected element at argument 2, got nil]
iPrestege Posted May 30, 2013 Posted May 30, 2013 Where's the 61 line post it here with the function .
Castillo Posted May 30, 2013 Posted May 30, 2013 addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) Move that to the function where you create the button.
Wes Posted May 30, 2013 Author Posted May 30, 2013 function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitLogin", localPlayer, username, password) guiSetInputEnabled(false) guiSetVisible(showLoginPanel, false) showCursor(false) end end end addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) ^^^^^^ This is the line 61
iPrestege Posted May 30, 2013 Posted May 30, 2013 UIEditor = { tabpanel = {}, window = {} } function showLoginPanel() GUIEditor.window[1] = guiCreateWindow(457, 348, 603, 277, "MTAProject Bejelentkezés & Regisztráció", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(27, 27, 544, 229, false, GUIEditor.window[1]) tabLogin = guiCreateTab("Bejelentkezés", GUIEditor.tabpanel[1]) username = guiCreateEdit(144, 25, 242, 30, "dsa", false, tabLogin) password = guiCreateEdit(144, 99, 242, 30, "dsa", false, tabLogin) bejelentkezes = guiCreateButton(144, 146, 236, 44, "Bejelentkezés", false, tabLogin) addEventHandler("onClientGUIClick", bejelentkezes, clientSubmitLogin, false) tabRegister = guiCreateTab("Regisztráció", GUIEditor.tabpanel[1]) regusername = guiCreateEdit(144, 25, 242, 30, "da", false, tabRegister) regpassword = guiCreateEdit(144, 99, 242, 30, "da", false, tabRegister) register = guiCreateButton(144, 146, 236, 44, "Regisztráció", false, tabRegister) --Regisztrációnál használatos label regFelhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabRegister) regJelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabRegister) guiSetFont(regFelhasznLabel, "default-bold-small") guiSetFont(regJelszoLabel, "default-bold-small") --Bejelentkezésnél használatos label felhasznLabel = guiCreateLabel(49, 32, 242, 30, "Felhasználónév:", false, tabLogin) jelszoLabel = guiCreateLabel(100, 105, 242, 30, "Jelszó:", false, tabLogin) guiSetFont(felhasznLabel, "default-bold-small") guiSetFont(jelszoLabel, "default-bold-small") showCursor(true) guiSetInputEnabled(true) end addEventHandler("onClientResourceStart", resourceRoot, showLoginPanel) function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitLogin", localPlayer, username, password) guiSetInputEnabled(false) guiSetVisible(showLoginPanel, false) showCursor(false) end end end
iPrestege Posted May 30, 2013 Posted May 30, 2013 I just add the event under the button or you can remove the function and event on start and everything will work fine .
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