Jump to content

Register Attempts


TorNix~|nR

Recommended Posts

Hello guys, I made a register max attemps for users, a maximum 3 accounts for each serial

but I don't know where is the problem, help please?

function register(username, password)

					if (getAccountCount(source) >= 3) then
				displayServerMessageLogin(source, "Error", "warning")
	    return
	end

	if not (username == "") then
		if not (password == "") then
			local account = getAccount(username, password)
			if (account == false) then
				local accountAdded = addAccount(tostring(username), tostring(password))
				if (accountAdded) then
					displayServerMessageLogin(source, "Login: "..username.."  |  Password: "..password.."", "confirm")
				else
					displayServerMessageLogin(source, "Error, please try again", "warning")
				end
			else
				displayServerMessageLogin(source, "This user name already exists", "warning")
			end
		else
			displayServerMessageLogin(source, "Type your password", "warning")
		end
	else
		displayServerMessageLogin(source, "Enter your username", "warning")
	end
end
addEvent("register", true)
addEventHandler("register", getRootElement(), register)

function getAccountCount(player)
    local serial = getPlayerSerial(player)
	local accounts = getAccountsBySerial(serial)
	
	if(accounts) and (type(accounts == "table")) then
	    return #accounts
	end
	return false
end

 

Link to comment

It was a little problem the code I post is correct, but I use the incorrect one

I use this

function getAccountCount(player)
    local serial = getPlayerSerial(player)
	local accounts = getAccountsBySerial(serial)
	
	if(accounts) and (type(accounts == "table")) then
	    return
	end
	return false
end

instead of

function getAccountCount(player)
    local serial = getPlayerSerial(player)
	local accounts = getAccountsBySerial(serial)
	
	if(accounts) and (type(accounts == "table")) then
	    return #accounts
	end
	return false
end

Thank you for asking.

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...