Electrosumm Posted April 12 Share Posted April 12 Dears, it says: ERROR: Client triggered serverside event loginAccount, but event is not added serverside Can someone check it why? I couldn't find the error. client.lua : -- Create the login GUI local loginWindow = guiCreateWindow(400, 300, 300, 200, "Login", false) local usernameLabel = guiCreateLabel(20, 30, 80, 20, "Username:", false, loginWindow) local usernameEdit = guiCreateEdit(100, 30, 160, 20, "", false, loginWindow) local passwordLabel = guiCreateLabel(20, 60, 80, 20, "Password:", false, loginWindow) local passwordEdit = guiCreateEdit(100, 60, 160, 20, "", false, loginWindow) local rememberCheckbox = guiCreateCheckBox(20, 90, 200, 20, "Remember me", false, false, loginWindow) local loginButton = guiCreateButton(20, 120, 120, 30, "Login", false, loginWindow) guiSetVisible( loginWindow, false ) -- Create the registration GUI local registerWindow = guiCreateWindow(400, 300, 300, 250, "Registration", false) local regUsernameLabel = guiCreateLabel(20, 30, 80, 20, "Username:", false, registerWindow) local regUsernameEdit = guiCreateEdit(100, 30, 160, 20, "", false, registerWindow) local regPasswordLabel = guiCreateLabel(20, 60, 80, 20, "Password:", false, registerWindow) local regPasswordEdit = guiCreateEdit(100, 60, 160, 20, "", false, registerWindow) local regConfirmLabel = guiCreateLabel(20, 90, 80, 20, "Confirm:", false, registerWindow) local regConfirmEdit = guiCreateEdit(100, 90, 160, 20, "", false, registerWindow) local regEmailLabel = guiCreateLabel(20, 120, 80, 20, "Email:", false, registerWindow) local regEmailEdit = guiCreateEdit(100, 120, 160, 20, "", false, registerWindow) local registerButton = guiCreateButton(20, 150, 120, 30, "Register", false, registerWindow) guiSetVisible( registerWindow, false ) -- Show the login GUI when the resource starts and show cursor addEventHandler("onClientResourceStart", resourceRoot, function() guiSetVisible( loginWindow, true ) showCursor( true ) end) -- Login Event addEventHandler("onClientGUIClick", loginButton, function() local username = guiGetText(usernameEdit) local password = guiGetText(passwordEdit) local rememberMe = guiCheckBoxGetSelected(rememberCheckbox) triggerServerEvent("loginAccount", resourceRoot, username, password, rememberMe) end, false) -- Register Event addEventHandler("onClientGUIClick", registerButton, function() local username = guiGetText(regUsernameEdit) local password = guiGetText(regPasswordEdit) local passwordAgain = guiGetText(regConfirmEdit) local email = guiGetText(regEmailEdit) triggerServerEvent("registerAccount", resourceRoot, username, password, passwordAgain, email) end, false) -- Login Success Event addEvent("onAccountLoggedIn", true) addEventHandler("onAccountLoggedIn", resourceRoot, function() -- Handle login success end) -- Login Failure Event addEvent("onAccountLoginFailed", true) addEventHandler("onAccountLoginFailed", resourceRoot, function() -- Handle login failure end) -- Registration Success Event addEvent("onAccountRegistered", true) addEventHandler("onAccountRegistered", resourceRoot, function() -- Handle registration success end) -- Registration Failure Event addEvent("onAccountRegistrationFailed", true) addEventHandler("onAccountRegistrationFailed", resourceRoot, function() -- Handle registration failure end) server.lua : addEvent("loginAccount", true) addEventHandler("loginAccount", resourceRoot, function(username, password, rememberMe) local player = client if not isPlayerBanned(player) then if handleLogin(username, password, rememberMe) then triggerClientEvent(player, "onAccountLoggedIn", player) else triggerClientEvent(player, "onAccountLoginFailed", player) end else triggerClientEvent(player, "onAccountBanned", player) end end) addEvent("registerAccount", true) addEventHandler("registerAccount", resourceRoot, function(username, password, passwordAgain, email) local player = client local ip = getPlayerIP(player) local serial = getPlayerSerial(player) if handleRegistration(username, password, passwordAgain, email, ip, serial) then triggerClientEvent(player, "onAccountRegistered", player) else triggerClientEvent(player, "onAccountRegistrationFailed", player) end end) meta.xml: <meta> <info author="" name="Account system" version="1.0" type="script" /> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> </meta> mysq/server.lua: -- Create a function to handle database queries function queryHandler(query, ...) local query = dbQuery(connection, query, ...) if not query then outputDebugString("Can't do the request") return end local result, num_affected_rows, last_insert_id = dbPoll(query, -1) return result, num_affected_rows, last_insert_id end Link to comment
FileEX Posted April 12 Share Posted April 12 Change resourceRoot to root in the loginAccount event on server-side 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