'~DaLesTe^' Posted July 22, 2015 Share Posted July 22, 2015 How can I put a message when there is already an established account? For example "There is already an account with this name" If Possible in dx function submitLogin (source, user, pass) if (user ~= "") then if (pass ~= "") then local acc = getAccount (user, pass) if (acc ~= false) then logIn (source, acc, pass) outputChatBox ("Você logou com sucesso.", source, 255, 255, 255, false) triggerClientEvent (source, "hideWindow", source) else outputChatBox ("Usuário ou senha incorretos. Cheque seus dados!", source, 255, 255, 255, false) end else outputChatBox ("A senha não pode ficar em branco.", source, 255, 255, 255, false) end else outputChatBox ("Usuário não pode ficar em branco.", source, 255, 255, 255, false) end end addEvent ("loginReq", true) addEventHandler ("loginReq", getRootElement(), submitLogin) addEvent ("registerReq", true) addEventHandler ("registerReq", getRootElement(), function (source, Nuser, Npass) if (Nuser ~= "" and Nuser ~= nil and Npass ~= "" and Npass ~= nil) then local Nacc = addAccount (Nuser, Npass) if Nacc then outputChatBox ("Você se registrou com sucesso! Agora faça seu login..", source, 255, 255, 255) end end end ) Link to comment
xXMADEXx Posted July 22, 2015 Share Posted July 22, 2015 You need to trigger an event back to the client using triggerClientEvent. Link to comment
'~DaLesTe^' Posted July 22, 2015 Author Share Posted July 22, 2015 How can I do this? I do not know: \ Link to comment
joaosilva099 Posted July 22, 2015 Share Posted July 22, 2015 you want to check if the account already exists on the register act? Link to comment
RaceXtreme Posted July 22, 2015 Share Posted July 22, 2015 Easy, just check the wiki https://wiki.multitheftauto.com/wiki/GetAccount. This function returns false if there's no account with the username specified. So the code looks just like the following: addEventHandler ("registerReq", getRootElement(), function (source, Nuser, Npass) if (Nuser ~= "" and Nuser ~= nil and Npass ~= "" and Npass ~= nil) then if getAccount (Nuser) then -- checks if account exists with this name outputChatBox ("Já existe uma conta com este nome.") return false end local Nacc = addAccount (Nuser, Npass) if Nacc then outputChatBox ("Você se registrou com sucesso! Agora faça seu login..", source, 255, 255, 255) end end end Also, avoid adding events with root element. It is much slower than using an player element, for example. Link to comment
'~DaLesTe^' Posted July 22, 2015 Author Share Posted July 22, 2015 Easy, just check the wiki https://wiki.multitheftauto.com/wiki/GetAccount. This function returns false if there's no account with the username specified. So the code looks just like the following: addEventHandler ("registerReq", getRootElement(), function (source, Nuser, Npass) if (Nuser ~= "" and Nuser ~= nil and Npass ~= "" and Npass ~= nil) then if getAccount (Nuser) then -- checks if account exists with this name outputChatBox ("Já existe uma conta com este nome.") return false end local Nacc = addAccount (Nuser, Npass) if Nacc then outputChatBox ("Você se registrou com sucesso! Agora faça seu login..", source, 255, 255, 255) end end end Also, avoid adding events with root element. It is much slower than using an player element, for example. Don't work Link to comment
RaceXtreme Posted July 22, 2015 Share Posted July 22, 2015 Well, there are many reasons to not work. You should tell me exactly what is happening in your game client. Try debugscript command to see what outputs. I've made a test and Npass was nil when "registerReq" was called. Take out the source parameter because it is already set as local variable in that function. Then give it a try: addEventHandler ("registerReq", getRootElement(), function (Nuser, Npass) if (Nuser ~= "" and Nuser ~= nil and Npass ~= "" and Npass ~= nil) then if getAccount (Nuser) then -- checks if account exists with this name outputChatBox ("Já existe uma conta com este nome.", source, 255, 255, 255) return false end local Nacc = addAccount (Nuser, Npass) if Nacc then outputChatBox ("Você se registrou com sucesso! Agora faça seu login..", source, 255, 255, 255) end end end ) Link to comment
'~DaLesTe^' Posted July 23, 2015 Author Share Posted July 23, 2015 Well, there are many reasons to not work. You should tell me exactly what is happening in your game client. Try debugscript command to see what outputs.I've made a test and Npass was nil when "registerReq" was called. Take out the source parameter because it is already set as local variable in that function. Then give it a try: addEventHandler ("registerReq", getRootElement(), function (Nuser, Npass) if (Nuser ~= "" and Nuser ~= nil and Npass ~= "" and Npass ~= nil) then if getAccount (Nuser) then -- checks if account exists with this name outputChatBox ("Já existe uma conta com este nome.", source, 255, 255, 255) return false end local Nacc = addAccount (Nuser, Npass) if Nacc then outputChatBox ("Você se registrou com sucesso! Agora faça seu login..", source, 255, 255, 255) end end end ) the panel is not logged in and did not create the account ERROR: Client ('~FN|+N#000000esTon^') triggered serverside event loginReq, but event is not added serverside Obs: This part of the script is serverside 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