• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 1.X+ I added an account manager

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
447
Solutions
11
Reaction score
331
Location
gamelaot.sytes.net
I added an account manager source tfs 1.2
I want the account manager to be at the top of the list at first
what should I do?
I don't want him to change his position with the names of the charactersabdalaaccount manger.png
 
Solution
Move
C++:
        if (account.id != 1){
            account.characters.push_back("Account Manager");
        }
after
C++:
std::sort(account.characters.begin(), account.characters.end());
Account manager has moved to the bottom of the list :D I want it at the top, not at the bottom
Thanks for trying to help me ♥♥
Post automatically merged:

I fixed it myself and found the solution
I really can't believe this I don't understand c++
All I did was start moving the lines above and this below and vice versa and try a lot
I did 8 compile until it worked
I thank this guy @samco for giving me hope and the idea of moving between the lines
look what i did
Lua:
bool IOLoginData::loginserverAuthentication(uint32_t accountName...
Probably something like this in iologindata.cpp in the function loginserverAuthentication
C++:
    result = db.storeQuery(fmt::format(
        "SELECT `name` FROM `players` WHERE `account_id` = {:d} AND `deletion` = 0 ORDER BY `name` ASC", account.id));
    if (result) {
        do {
            if(result->getString("name") == "Account Manager"){
                account.characters.insert(account.characters.begin(), result->getString("name"));
            } else {
                account.characters.push_back(result->getString("name"));
            }
        } while (result->next());
    }
 
Probably something like this in iologindata.cpp in the function loginserverAuthentication
C++:
    result = db.storeQuery(fmt::format(
        "SELECT `name` FROM `players` WHERE `account_id` = {:d} AND `deletion` = 0 ORDER BY `name` ASC", account.id));
    if (result) {
        do {
            if(result->getString("name") == "Account Manager"){
                account.characters.insert(account.characters.begin(), result->getString("name"));
            } else {
                account.characters.push_back(result->getString("name"));
            }
        } while (result->next());
    }
i replace my code to you'r code and compile without error but in login im get debug client

Lua:
bool IOLoginData::loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account)
{
    Database* db = Database::getInstance();

    std::ostringstream query;
    query << "SELECT id, name, password, type, premdays, lastday FROM accounts WHERE name = " << accountName;
    DBResult_ptr result = db->storeQuery(query.str());
    if (!result) {
        return false;
    }

    if (transformToSHA1(password) != result->getString("password")) {
        return false;
    }

    account.id = result->getNumber<uint32_t>("id");
    account.name = result->getNumber<uint32_t>("name");
    account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
    account.premiumDays = result->getNumber<uint16_t>("premdays");
    account.lastDay = result->getNumber<time_t>("lastday");

    query.str(std::string());
    query << "SELECT name, deletion FROM players WHERE account_id = " << account.id;
    result = db->storeQuery(query.str());
   
    if(!result){
        account.characters.push_back("Account Manager");
        return true;
    }

    if (result) {
        if (account.id != 1){
            account.characters.push_back("Account Manager");
        }
        do {
            if (result->getNumber<uint64_t>("deletion") == 0) {
                account.characters.push_back(result->getString("name"));
            }
        }
        while (result->next());
        std::sort(account.characters.begin(), account.characters.end());
    }
    return true;
}
 
This is my file please help me show the account manager in the first value iologindata.cpp
This line:
Code:
std::sort(account.characters.begin(), account.characters.end());
sorts characters by name alphabetically.
You can't sort them after adding Account Manager to list.
 
Move
C++:
        if (account.id != 1){
            account.characters.push_back("Account Manager");
        }
after
C++:
std::sort(account.characters.begin(), account.characters.end());
 
Move
C++:
        if (account.id != 1){
            account.characters.push_back("Account Manager");
        }
after
C++:
std::sort(account.characters.begin(), account.characters.end());
Account manager has moved to the bottom of the list :D I want it at the top, not at the bottom
Thanks for trying to help me ♥♥
Post automatically merged:

I fixed it myself and found the solution
I really can't believe this I don't understand c++
All I did was start moving the lines above and this below and vice versa and try a lot
I did 8 compile until it worked
I thank this guy @samco for giving me hope and the idea of moving between the lines
look what i did
Lua:
bool IOLoginData::loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account)
{
    Database* db = Database::getInstance();

    std::ostringstream query;
    query << "SELECT `id`, `name`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `name` = " << accountName;
    DBResult_ptr result = db->storeQuery(query.str());
    if (!result) {
        return false;
    }

    if (transformToSHA1(password) != result->getString("password")) {
        return false;
    }

    account.id = result->getNumber<uint32_t>("id");
    account.name = result->getNumber<uint32_t>("name");
    account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
    account.premiumDays = result->getNumber<uint16_t>("premdays");
    account.lastDay = result->getNumber<time_t>("lastday");

    query.str(std::string());
    query << "SELECT `name`, `deletion` FROM `players` WHERE `account_id` = " << account.id;
    result = db->storeQuery(query.str());
   
    if(!result){
        // give the account the account manager to use if they have no account
        account.characters.push_back("Account Manager");
        return true;
    }
    // --
    if (result) {
        // allow them to access the account manager if there are players on the account
        if (account.id != 1){
            account.characters.push_back("Account Manager");
        }
        std::sort(account.characters.begin(), account.characters.end());
        do {
            if (result->getNumber<uint64_t>("deletion") == 0) {
                account.characters.push_back(result->getString("name"));
            }
        } while (result->next());
    }
    return true;
}
acctoplist.png
 
Last edited:
Solution
If you are not doing the sort after every insertion of the characters, you dont need it after the account manager insertion, but character list wont be alphabetically ordered

Now im at PC, please try this one @abdala ragab :


C++:
    // --
    if (result) {
        do {
            if (result->getNumber<uint64_t>("deletion") == 0) {
                account.characters.push_back(result->getString("name"));
            }
        } while (result->next());
        std::sort(account.characters.begin(), account.characters.end());
        // allow them to access the account manager if there are players on the account
        if (account.id != 1){
            account.characters.emplace(account.characters.begin(),"Account Manager");
        }
    }
    return true;
 
Last edited:
Back
Top