Jump to content

Can't solve problem


Protagonist95

Recommended Posts

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 by Protagonist95
Link to comment

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
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
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
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
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 by Protagonist95
  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...