• 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!

[REQUEST] Team System

Andrzej221

New Member
Joined
Aug 19, 2007
Messages
22
Reaction score
0
Well, i wanna the Code like "Team System".

It is like when:

if Team1 got more players than Team2

then players what trying to login on team1 going to team2 (auto)

same as if Team2 got more players than Team1 then ...

I trying to do it basing on code from HotServ created by Rex

Code:
                        Account account;
                        if(g_config.getString(ConfigManager::TEAM_SYSTEM) == "yes")
                        {
                           int32_t Team1 = 0, Team2 = 0;
                           unsigned short loadTeam = 0;
                           AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
                           while(it != Player::listPlayer.list.end())
                           {
                              if((*it).second->accountNumber == 1)
                                  Team1 += 1;
                              else if((*it).second->accountNumber == 2)
                                  Team2 += 1;
                              ++it;
                           }
                           if(Team1 > Team2)
                           {
                              loadTeam = 2;
                              accnumber = 2;
                              password = "2";
                           }
                           else if(Team2 > Team1)
                           {
                              loadTeam = 1;
                              accnumber = 1;
                              password = "1";
                           }
                           account = IOLoginData.loadAccount((int)loadTeam);
                        }
                        else
                        {
                            if(accnumber != 2 || accnumber != 1)
                               account = IOLoginData.loadAccount(accnumber);
                        }

When i replace above code with:

Code:
Account account = IOLoginData.loadAccount(accnumber);

Then i can't load account when trying to login.

Help me please
 
Last edited:
I use empty SVN, but when writing code on this forum i change IOAccount::instance() to IOLoginData like Forgotten Server...

And this is my error when i change code ^.-

Code:
Account account;
                        if(g_config.getString(ConfigManager::TEAM_SYSTEM) == "yes")
                        {
                           int32_t Team1 = 0, Team2 = 0;
                           unsigned short loadTeam = 0;
                           AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
                           while(it != Player::listPlayer.list.end())
                           {
                              if((*it).second->accountNumber == 1)
                                  Team1 += 1;
                              else if((*it).second->accountNumber == 2)
                                  Team2 += 1;
                              ++it;
                           }
                           if(Team1 > Team2)
                           {
                              loadTeam = 2;
                              accnumber = 2;
                              password = "2";
                           }
                           else if(Team2 > Team1)
                           {
                              loadTeam = 1;
                              accnumber = 1;
                              password = "1";
                           }
                           account = IOAccount::instance()->loadAccount((int)loadTeam);
                        }
                        else
                        {
                            if(accnumber != 2 || accnumber != 1)
                               account = IOAccount::instance()->loadAccount(accnumber);
                        }
 
Last edited:
It seems you are loading the Team1/2 variables inside the loadPlayer(or w/e it is called) function. You should declare those variables outside any function and then do something with them there.
 
No. It's code for "auto balance". When player login on account 1/1 server show him list of characters from account 1 or 2.
 
Back
Top