Jump to content

registering proplem


Anthony

Recommended Posts

function registerPlayer(username,password,passwordConfirm)
    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
                            outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password .. "#00FF00 ]",source,255,255,255,true )
                        else
                            triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An unknown error has occured! Please choose a different username/password and try again.")
                        end
                    else
                        triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","An account with this username already exists!")
                    end
                else
                    triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Passwords do not match!")
                end
            else
                triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please confirm your password!")
            end
        else
            triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a password!")
        end
    else
        triggerClientEvent(source,"set_warning_text",getRootElement(),"Register","Please enter a username you would like to register with!")
    end
end
addEvent("onRequestRegister",true)
addEventHandler("onRequestRegister",getRootElement(),registerPlayer)

wheni press the register key the debug says that the resource can't add account as in :

                        local accountAdded = addAccount(tostring(username),tostring(password))

Link to comment

test this code and please use the code tag when you put another code

 

function registerPlayer ( username, password1, password2 )
	if not ( isObjectInACLGroup ( "resource."..( getResourceName ( getThisResource ( ) ) ),aclGetGroup ( "Admin" ) ) ) then
		outputChatBox ( "This resource is not in acl group 'admin' !!", client, 255, 0, 0 )
		return false
	end
	if username == "" and password1 == "" and password2 == "" then
		triggerClientEvent( client,"set_warning_text",client,"Register","write all of information please" )
		return false
	end
	if password1 ~= password2 then
		triggerClientEvent( client,"set_warning_text",client,"Register","passowrds error" )
		return false
	end
	if getAccount ( username ) then
		triggerClientEvent( client,"set_warning_text",client,"Register","An account with this username already exists!" )
		return false
	end
	if ( addAccount( username , tostring( password1 ) ) ) then
		outputChatBox ("#FF0000* #00FF00You have sucessfuly registered! [Username: #FFFFFF" .. username .. " #00FF00| Password: #FFFFFF" .. password1 .. "#00FF00 ]",source,255,255,255,true )
	end
end
addEvent( "onRequestRegister", true )
addEventHandler( "onRequestRegister" ,root ,registerPlayer )

 

Edited by killerProject
edited for Abdul KariM
Link to comment
Just now, Abdul KariM said:

@killerProject You code doesn't working for several reasons


1 = if it was resource in group admin will return false

2= if username is not empty or password will return false

sorry about this ..
 

if not ( isObjectInACLGroup ( "resource."..( getResourceName ( getThisResource ( ) ) ),aclGetGroup ( "Admin" ) ) ) then

 

if username == "" and password1 == "" and password2 == "" then

 

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