Jump to content

Serials


TorNix~|nR

Recommended Posts

Hi guys, I working on script thats make players can't register more two account but don't work and when test to see how many accounts i have i see one account but i registered more then 3 accounts but when i see database (internal.db) i see my accounts don't register ip and serial
sorry for my english

17500254_1309683035733682_448473703_o.pn

Link to comment

when someone register's just set new value for account data

setAccountData(account-here,"serial",getPlayerSerial(player-here));

and then just find all accounts with data serial and if they are more than 2 that are equal to player's serial then just cancel register, simple as that.

  • Like 1
Link to comment

 

I dont know how you can make that maybe the pro can help you. @NeXuS™, when the serial is used, but something this:

 

local bRegisteredOnce = false
addCommandHandler("register",function(source,commandName,username,password)
local theSerial = getPlayerSerial( source ) --> Serial 
    -- Here something for cancelevent if the serial in use

        if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false and (string.len(username)>=4) and (string.len(password)>=4) ) then
                local accountAdded = addAccount(username,password)
                if(accountAdded) then
                        outputChatBox("Account added",source)
                        local account = getAccount(username,password)
                        
                        setAccountData(account,"Serial",theSerial)

                        bRegisteredOnce = true
                else
                end
        else
                if bRegisteredOnce == true then
                else
            end
    end
end)
Edited by TheMOG
Link to comment

Use this check at register Whether login-panel or admin-panel

And do not forget the definition of the player

	if ( #getAccountsBySerial ( getPlayerSerial ( source ) ) >= 1 ) then
	
	-- You're Code For example outputChatBox - it's a don't he can register more from one account
	
		return
	end
	


 

Link to comment
17 minutes ago, Abdul KariM said:

Use this check at register Whether login-panel or admin-panel

And do not forget the definition of the player


	if ( #getAccountsBySerial ( getPlayerSerial ( source ) ) >= 1 ) then
	
	-- You're Code For example outputChatBox - it's a don't he can register more from one account
	
		return
	end
	


 

The main problem with this is if you register your account, but don't LOG IN, your serial wont be saved into the database, and you can register as many accounts as you want.

Link to comment

@Abdul KariM thats it what the guy need.

here you go all in one

 

 

addCommandHandler("register",function(source,cmd,username,password)
if (#getAccountsBySerial(getPlayerSerial(source)) >= 1 ) then outputChatBox("You are already registered!.",source,255,255,255,true) return end
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and (string.len(username)>=4) and (string.len(password)>=4) ) then
local accountCreated = addAccount(username,password)
    if (accountCreated) then       
        outputChatBox("You Succesfully registered.",source,255,0,0,true)         
    else
        outputChatBox("Contact with the admin.",source,255,0,0,true)
    end    
else
    outputChatBox("The username and password must be 4 character.",source,255,0,0,true)
    outputChatBox(" /register [Username] [Password]",source,255,255,255,true)
end
end)

 

Link to comment
6 hours ago, TheMOG said:

@Abdul KariM thats it what the guy need.

here you go all in one

 

 


addCommandHandler("register",function(source,cmd,username,password)
if (#getAccountsBySerial(getPlayerSerial(source)) >= 1 ) then outputChatBox("You are already registered!.",source,255,255,255,true) return end
if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and (string.len(username)>=4) and (string.len(password)>=4) ) then
local accountCreated = addAccount(username,password)
    if (accountCreated) then       
        outputChatBox("You Succesfully registered.",source,255,0,0,true)         
    else
        outputChatBox("Contact with the admin.",source,255,0,0,true)
    end    
else
    outputChatBox("The username and password must be 4 character.",source,255,0,0,true)
    outputChatBox(" /register [Username] [Password]",source,255,255,255,true)
end
end)

 

This one won't work either, because of IP and serial are set during login.
 

Link to comment
local maxAccountAmout = 3
	
local query = executeSQLQuery ( "SELECT * FROM accounts WHERE serial=?", getPlayerSerial ( source ) )
if ( query and #query >= maxAccountAmout ) then
	outputChatBox("You can't register more than "..maxAccountAmout.." accounts.", source, 0, 255, 0)
	return false
end

I was hesitating about posting this but i hope it works.

Link to comment
1 hour ago, Thrzu said:

local maxAccountAmout = 3
	
local query = executeSQLQuery ( "SELECT * FROM accounts WHERE serial=?", getPlayerSerial ( source ) )
if ( query and #query >= maxAccountAmout ) then
	outputChatBox("You can't register more than "..maxAccountAmout.." accounts.", source, 0, 255, 0)
	return false
end

I was hesitating about posting this but i hope it works.

Again, won't work. Check my comment above bud. Your IP and serial gets set into the database when you LOG IN. So if you just have a register, but no login, you can register as many accounts as you want.

Link to comment
  • MTA Team

What about modifying the register command to also log the player in, so the serial and ip get set.
Something like:

if ( #getAccountsBySerial(getPlayerSerial(thePlayer)) == 0 )
    logOut( thePlayer )
    local account = addAccount( username, password )
    logIn( thePlayer, account, password )
    logOut( thePlayer )
end

 

Link to comment

guys thanks for replying

@TheMOG I won't it by command. I want it with the panel

this is the Register, @xeon17 helped me on this

Code

-- Registration here
function registerPlayer(username,password,passwordConfirm)

	if (getAccountCount(source) >= 2) then
	    return
	end
		
	if not (username == "") then
		if not (password == "") then
			if not (passwordConfirm == "") then
				if password == passwordConfirm then
					local account = getAccount (username,password)
					if (account == false) then
						local accountAdded = addAccount(tostring(username),tostring(password))
						if (accountAdded) then
							triggerClientEvent(source,"hideRegisterWindow",getRootElement())
							outputChatBox ("#0000FF* #FFFFFFYou have sucessfuly registered! [Username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",source,255,255,255,true )	
							setTimer(outputChatBox,800,1,"#0000FF* #FFFFFFYou can now login with your new account.",source,255,255,255,true )
						else
							outputChatBox ("#0000FF* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",source,255,255,255,true )
						end
					else
						outputChatBox ("#0000FF* #FFFFFFError! An account with this username already exists!",source,255,255,255,true )
					end
				else
					outputChatBox ("#0000FF* #FFFFFFError! Passwords do not match!",source,255,255,255,true)
				end
			else
				outputChatBox ("#0000FF* #FFFFFFError! Please confirm your password!",source,255,255,255,true)
			end
		else
			outputChatBox ("#0000FF* #FFFFFFError! Please enter a password!",source,255,255,255,true)
		end
	else
		outputChatBox ("#0000FF* #FFFFFFError! Please enter a username you would like to register with!",source,255,255,255,true)
	end
end

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
-- Registration here
function registerPlayer(username,password,passwordConfirm)

	if (getAccountCount(source) >= 2) then
	    return
	end
		
	if not (username == "") then
		if not (password == "") then
			if not (passwordConfirm == "") then
				if password == passwordConfirm then
					local account = getAccount (username,password)
					if (account == false) then
						local accountAdded = addAccount(tostring(username),tostring(password))
						if (accountAdded) then
							triggerClientEvent(source,"hideRegisterWindow",getRootElement())
							outputChatBox ("#0000FF* #FFFFFFYou have sucessfuly registered! [Username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",source,255,255,255,true )
							logOut(source)
							logIn(source, accountAdded, password)
							logOut(source)
							setTimer(outputChatBox,800,1,"#0000FF* #FFFFFFYou can now login with your new account.",source,255,255,255,true )
						else
							outputChatBox ("#0000FF* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",source,255,255,255,true )
						end
					else
						outputChatBox ("#0000FF* #FFFFFFError! An account with this username already exists!",source,255,255,255,true )
					end
				else
					outputChatBox ("#0000FF* #FFFFFFError! Passwords do not match!",source,255,255,255,true)
				end
			else
				outputChatBox ("#0000FF* #FFFFFFError! Please confirm your password!",source,255,255,255,true)
			end
		else
			outputChatBox ("#0000FF* #FFFFFFError! Please enter a password!",source,255,255,255,true)
		end
	else
		outputChatBox ("#0000FF* #FFFFFFError! Please enter a username you would like to register with!",source,255,255,255,true)
	end
end

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

This one should work without any problems. Your code above has a problem in it, which we were discussing above.

Edited by NeXuS™
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...