Jump to content

Allowing users to create multiple accounts


Cinematic

Recommended Posts

In server.lua for the account system I was told to freeze some lines. But it doesn't work, only breaks the script. Here's the lines:

 

local [[preparedQuery2 = "SELECT mtaserial FROM account_details WHERE mtaserial='".. toSQL(mtaSerial) .."' LIMIT 1"
                local Q2 = mysql:query(preparedQuery2)
                if not Q2 then
                    triggerClientEvent(client,"set_warning_text",client,"Register","Error code 0003 occurred.")
                    return false
                end

                local usernameExisted = mysql:fetch_assoc(Q2)
                if (mysql:num_rows(Q2) > 0) and usernameExisted["id"] ~= "1" then
                    triggerClientEvent(client,"set_warning_text",client,"Register","Multiple Accounts is not allowed (Existed: "..tostring(usernameExisted["username"])..")")
                    return false
                end
                mysql:free_result(Q2)

 

HsDHrSg.pngM348jab.png

Link to comment

Really messed something up now. Novice at scripting so bear with me, but I deleted and reuploaded the MySQL and now I have this error when trying to login. Not sure what I have to do from here to get it working again.

zyJofmi.png

YXtNQkd.png

Edited by Cinematic
Link to comment

Hi!  - Firstly I will turn back to your first problem, to the multiple account thing. You shouldn't /overthink/ your script, because it's very confusing what I'm seeing now.(for me at least ? ) You should try to attach the multiple account creation to serial(s) like this, but now, in serverside:

local serials = { -- You can type here the serial, which you want to grant permission to create multiple account(s)
	[""]= true,
}

function onRegisterClick(player, username, password, email)
	local password = md5(password)
	local registerQuery = dbPoll(dbQuery(connection, "SELECT * FROM mta.accounts"), -1)
	for _, row in ipairs(registerQuery) do
		if row["mtaserial"] == getPlayerSerial(player) and not serials[getPlayerSerial(player)] then
			   triggerClientEvent(client,"set_warning_text",client,"Register","Multiple Accounts is not allowed (Existed: "..tostring(usernameExisted["username"])..")") 
			return
		end
	end

The last problem, i think you screwed up some dbPoll(maybe you typed a different path or something) in the script, that's why it doesn't find it. - You should try to look in the sql and between the script to find out how you named your accounts table.

P.S: Sorry for the bad english, i hope you can understand something at least.. :D

Edited by Flashmyname
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...