Jump to content

Error while using addAccount


Recommended Posts

Goodday everybody,

The function addAccount returns false when I'm calling it, I put the resource where I'm calling the function in the right acl group.

The user I'm trying to register does not exist.

The server console doesn't give any errors or reasons why the function wont create the account.

I'm developing my server on a nightly build of mta 1.1 (without voice).

The peace of code that does all this fun stuff:

function mrCreateAccount(username, password, data) 
    if #getAccounts() >= MAX_ACCOUNTS then 
        return false, ACCOUNT_CREATION_ERRORS.ACCOUNT_LIMIT_REACHED; 
    end 
     
    -- removeAccount(getAccount(username)); 
     
    if getAccount(username) then 
        return false, ACCOUNT_CREATION_ERRORS.ACCOUNT_EXISTS; 
    end 
     
    local p, salt = hashPassword(username, password); 
     
    local newAccount = addAccount(username, p); 
     
    if newAccount ~= false then 
        local ingame_key = md5(username .. SERVER_BOOLFISH .. p); 
        if not data['sql'] then 
            data['sql'] = {}; 
        end 
         
        data['sql']['ingame_api_key'] = ingame_key; 
        data['sql']['username'] = username; 
        data['sql']['password'] = p; 
        data['sql']['salt'] = salt; 
         
        local newData = exports.mj_utils_lib:tableExtend(DEFAULT_SQL_DATA, data['sql']); 
        local result, error = exports.mj_sql_lib:query_insertid("INSERT INTO mr_accounts (username, password, autologin, autologinhash, salt, email, enabled, game_enabled, banned, banned_till, warnings, ingame_api_key, newsletter, birthday) VALUES ('%s', '%s', %s, '%s', '%s', '%s', %s, %s, %s, '%s', %s, '%s', %s, '%s')", 
            newData.username, 
            newData.password, 
            newData.autologin, 
            newData.autologinhash, 
            newData.salt, 
            newData.email, 
            newData.enabled, 
            newData.game_enabled, 
            newData.banned, 
            newData.banned_till, 
            newData.warnings, 
            newData.ingame_api_key, 
            newData.newsletter, 
            newData.birthday); 
        if not result then 
            print(error); 
            removeAccount(newAccount); 
             
            return false, "UNKNOWN_ERROR"; 
        end 
         
        return true, mrGetAccount(newAccount); 
    end 
     
    print(tostring(newAccount)); 
         
    return false, "Account creation error"; 
end 

All the functions and exported functions called in this peace of code does exists. The resources of the exported functions are started.

Mr. de Jong

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