Protagonist95 Posted December 9, 2016 Share Posted December 9, 2016 (edited) Cant trigger login function after creating account function onGuestAccount() local serial = getPlayerSerial(source) local account = getAccount(tostring(getPlayerSerial(source))) if (account ~= false) then logIn(source,account,"****") outputChatBox("Welcome back!") else addAccount(serial,"****") logIn(source,account,"****") end end addEventHandler ( "onPlayerJoin", getRootElement(), onGuestAccount ) logIn(source,account,"****") ---> boolean error Edited December 9, 2016 by Protagonist95 Link to comment
Protagonist95 Posted December 9, 2016 Author Share Posted December 9, 2016 Unfortunately the "else" method doesn't work,so i solved it with recursion function onGuestAccount() local serial = getPlayerSerial(source) local account = getAccount(tostring(getPlayerSerial(source))) if (account ~= false) then logIn(source,account,"****") outputChatBox("Welcome back!") else addAccount(serial,"****") -- checked onGuestAccount() end end addEventHandler ( "onPlayerJoin", getRootElement(), onGuestAccount ) Link to comment
ViRuZGamiing Posted December 9, 2016 Share Posted December 9, 2016 getAccount(tostring(getPlayerSerial(source))) This won't give an error but would not work, since getAccount asks for a string that represents the username, you're giving a string that represents the user serial. Both are strings. I think you ment to do: getAccount(getPlayerName(source)) Link to comment
Protagonist95 Posted December 9, 2016 Author Share Posted December 9, 2016 7 minutes ago, ViRuZGamiing said: getAccount(tostring(getPlayerSerial(source))) This won't give an error but would not work, since getAccount asks for a string that represents the username, you're giving a string that represents the user serial. Both are strings. I think you ment to do: getAccount(getPlayerName(source)) No,i actually meant serial ID.I mentioned to do login system,that generates unique login and password,so you are able to create account once. Link to comment
ViRuZGamiing Posted December 9, 2016 Share Posted December 9, 2016 Do keep in mind the serial does change, for example reinstalling could change the serial and people won't be able to play from different pc's Link to comment
Protagonist95 Posted December 9, 2016 Author Share Posted December 9, 2016 34 minutes ago, ViRuZGamiing said: Do keep in mind the serial does change, for example reinstalling could change the serial and people won't be able to play from different pc's Yeah,but at the same time how often do you reinstall your OS.Also if u're managing to create like DayZ server(for example,but im not sure) you're not really dependent of your account. Link to comment
ViRuZGamiing Posted December 9, 2016 Share Posted December 9, 2016 9 minutes ago, Protagonist95 said: Yeah,but at the same time how often do you reinstall your OS.Also if u're managing to create like DayZ server(for example,but im not sure) you're not really dependent of your account. Not just the OS, reinstalling MTA does it as well (when deleting all remains, been there and used it as work around to create multiple accounts on a same server type) but about the code, what does Debuglog tell you at the moment, still boolean? Link to comment
Protagonist95 Posted December 9, 2016 Author Share Posted December 9, 2016 (edited) 8 minutes ago, ViRuZGamiing said: Not just the OS, reinstalling MTA does it as well (when deleting all remains, been there and used it as work around to create multiple accounts on a same server type) but about the code, what does Debuglog tell you at the moment, still boolean? No,as I already said, I solved it.Works fine.Also planing on small algorithm for password.If you are interested i can share it. Edited December 9, 2016 by Protagonist95 1 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