• 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+ [tfs 1.3] premium account can log 3 character in same acc.

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
As the title says, how do I get premium account to be able to login 3 characters in the same account?
and free account only 1.

C++:
        if (g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && g_game.getPlayerByAccount(player->getAccount())) {
            disconnectClient("You may only login with one character\nof your account at the same time.");
            return;
        }
 
Solution
Actaully i cannot guarantee it will work for 100% bcs i do not have access to compiler now but try something like this:

C++:
if (g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && g_game.getPlayerByAccount(player->getAccount())) {
    if (player->isPremium()) {
        int onlineChars = 0;
        for (const auto& it : players) {
            if (it.second->getAccount() == player->getAccount())
                onlineChars++;
        }
        if (onlineChars > 3) {
            disconnectClient("You may only login with three characters\nof your account at the same time.");
            return;
        }
    } else {
        disconnectClient("You may only login with one...
Actaully i cannot guarantee it will work for 100% bcs i do not have access to compiler now but try something like this:

C++:
if (g_config.getBoolean(ConfigManager::ONE_PLAYER_ON_ACCOUNT) && player->getAccountType() < ACCOUNT_TYPE_GAMEMASTER && g_game.getPlayerByAccount(player->getAccount())) {
    if (player->isPremium()) {
        int onlineChars = 0;
        for (const auto& it : players) {
            if (it.second->getAccount() == player->getAccount())
                onlineChars++;
        }
        if (onlineChars > 3) {
            disconnectClient("You may only login with three characters\nof your account at the same time.");
            return;
        }
    } else {
        disconnectClient("You may only login with one character\nof your account at the same time.");
        return;
    }
}

Short explaination:

You are checking if player is premium.
If not - disconnect client.
If yes - iterate over all online players and increment onlineChars every time iterator founds online char with acc id same as char requesting login.
Then just check if onlineChars doesn't exceed 3 and depending on result either accept or refuse connection from client.

If you want make it more flexible move the max allowed players logged count to place where you don't need to recompile tfs every time you change its value (config obviously)
 
Last edited:
Solution
Try replacing:
C++:
for (const auto& it : players) {
with:
C++:
for (const auto& it : g_game.getPlayers()) {

#Edit
Why it was not working:
I tried to call "players" which is not defined inside given scope. Instead i should use "g_game.getPlayers()" getter. It was source of "E0020: identifier "players" is undefined" error
 
Last edited:
Try replacing:
C++:
for (const auto& it : players) {
with:
C++:
for (const auto& it : g_game.getPlayers()) {

#Edit
Why it was not working:
I tried to call "players" which is not defined inside given scope. Instead i should use "g_game.getPlayers()" getter. It was source of "E0020: identifier "players" is undefined" error
now compiled normal, but did not work the script.
both free and vip account can log in more than 3 characters (in same acc)
 
now compiled normal, but did not work the script.
both free and vip account can log in more than 3 characters (in same acc)

This function checks if player have premium account (PACC), Propably you have separte VIP status then. Try removing PACC Time from account and check, if it works, You just need to replace player->isPremium() with another function that will check if player have VIP status
 
This function checks if player have premium account (PACC), Propably you have separte VIP status then. Try removing PACC Time from account and check, if it works, You just need to replace player->isPremium() with another function that will check if player have VIP status

I liked you for trying to help, but still the error persists.
I use the standard tfs premium account system without any changes

edit: how can a print something in the console? i tried:
Code:
printf("2");
but dont have success
 
player->isPremium() returns false if player does not have premium status, if statement is false rest of code is skipped and else/else if is executed (if present). In this script if player is not premium, only else is executed (disconnecting client), I can't really see any more mistakes in code so unfortunately only thing i can do is to ask You to check if there is no enabled free-premium, and try to set premdays manually to 0 inside database and then check again and eventually write what happened
 
player->isPremium() returns false if player does not have premium status, if statement is false rest of code is skipped and else/else if is executed (if present). In this script if player is not premium, only else is executed (disconnecting client), I can't really see any more mistakes in code so unfortunately only thing i can do is to ask You to check if there is no enabled free-premium, and try to set premdays manually to 0 inside database and then check again and eventually write what happened
Found the error, only change
(onlineChars > 3) to (onlineChars >= 3)
Thx bro!
 
Back
Top