Very important - Rules change on otservlist.org

Joined
Dec 16, 2015
Messages
138
Best answers
0
Likes
1
Location
Poland
#81
I've created a working code you can implement in your server.

protocolstatus.cpp (TFS 1.0/1.1/1.2)
Someone can do it for 8.6

@xinn @Sir Knighter @Flatlander

Change:
Code:
players.append_attribute("online") = std::to_string(g_game.getPlayersOnline()).c_str();
To this:

Code:
uint32_t real = 0;

std::map<uint32_t, uint32_t> listIP;

for (const auto& it : g_game.getPlayers()) {
   if (it.second->getIP() != 0) {
      auto ip = listIP.find(it.second->getIP());
      if (ip != listIP.end()) {
         listIP[it.second->getIP()]++;
         if (listIP[it.second->getIP()] < 5) {
            real++;
         }
      } else {
         listIP[it.second->getIP()] = 1;
         real++;
      }
   }
}
players.append_attribute("online") = std::to_string(real).c_str();
Could someone make it for 0.4 TFS?
 

mameca123

www.TheHeroesOfTime.com
Joined
Nov 19, 2008
Messages
20
Best answers
0
Likes
0
#82
EDIT: Nevermind, Xinn already answered my email.
 
Last edited:

login12

void newbie scripter()
Joined
Feb 26, 2011
Messages
134
Best answers
0
Likes
8
Location
Brazil
#83
Hello @xinn. I have problem and doubt. Sorry my bad english.
Well i have the code posted by @gunz in my server. WarkingOT.com

Code:
uint32_t real = 0;

std::map<uint32_t, uint32_t> listIP;

for (const auto& it : g_game.getPlayers()) {
   if (it.second->getIP() != 0) {
      auto ip = listIP.find(it.second->getIP());
      if (ip != listIP.end()) {
         listIP[it.second->getIP()]++;
         if (listIP[it.second->getIP()] < 5) {
            real++;
         }
      } else {
         listIP[it.second->getIP()] = 1;
         real++;
      }
   }
}
players.append_attribute("online") = std::to_string(real).c_str();
But i got ban from otservlist because players are using mc. I dont understand.
This code is fail? Can you check that?
 
Joined
Dec 16, 2015
Messages
138
Best answers
0
Likes
1
Location
Poland
#84
@xinn
Can we get code for TFS 0.4? Many players can not log because their friends using the same net are already logged in the game.
 

bobxM

Nostalrius Team
Joined
Jul 12, 2012
Messages
137
Best answers
0
Likes
8
Location
Brazil
#85
I'm trying use the rule at my iptables but it doesn't make effect. Someone knows why ?

# Debian 8.7
iptables -A INPUT -p tcp --dport 7172 -m connlimit --connlimit-above 4 -j DROP
 
Joined
Jul 8, 2016
Messages
119
Best answers
5
Likes
7
Location
Croatia
#86
Can someone help me with this? Im on tfs 0.3.6 linux, can someone give me a working code? Dont want to get banned for a month again...
 
Joined
Jun 5, 2011
Messages
383
Best answers
0
Likes
4
#87
I've created a working code you can implement in your server.

protocolstatus.cpp (TFS 1.0/1.1/1.2)
Someone can do it for 8.6

@xinn @Sir Knighter @Flatlander

Change:
Code:
players.append_attribute("online") = std::to_string(g_game.getPlayersOnline()).c_str();
To this:

Code:
uint32_t real = 0;

std::map<uint32_t, uint32_t> listIP;

for (const auto& it : g_game.getPlayers()) {
   if (it.second->getIP() != 0) {
      auto ip = listIP.find(it.second->getIP());
      if (ip != listIP.end()) {
         listIP[it.second->getIP()]++;
         if (listIP[it.second->getIP()] < 5) {
            real++;
         }
      } else {
         listIP[it.second->getIP()] = 1;
         real++;
      }
   }
}
players.append_attribute("online") = std::to_string(real).c_str();

Do you know the change for tfs 0.4?
 
Joined
Mar 11, 2017
Messages
45
Best answers
0
Likes
9
#88
Anybody has 0.4 source code?
I didn't set my server on otservlist.org because i dont find it yet and i dont want to be banned.
 
Joined
Jan 8, 2017
Messages
50
Best answers
1
Likes
17
#89
Code for 0.4. (not tested)
@xinn

Change this:
Code:
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);
To this:
Code:
uint32_t real = 0;
std::map<uint32_t, uint32_t> listIP;
for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) {
   if (it->second->getIP() != 0) {
       uint32_t ip = listIP.find(it->second->getIP());
       if (ip != listIP.end()) {
           listIP[it->second->getIP()]++;
           if (listIP[it->second->getIP()] < 5) {
               real++;
           }
       } else {
           listIP[it->second->getIP()] = 1;
           real++;
       }
   }
}
sprintf(buffer, "%d", real);
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);
 
Last edited:
Joined
Aug 6, 2012
Messages
133
Best answers
1
Likes
0
Location
Poland
#90
Code for 0.4. (not tested)
@xinn

Change this:
Code:
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);
To this:
Code:
uint32_t real = 0;
std::map<uint32_t, uint32_t> listIP;
for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) {
   if (it->second->getIP() != 0) {
       uint32_t ip = listIP.find(it->second->getIP());
       if (ip != listIP.end()) {
           listIP[it->second->getIP()]++;
           if (listIP[it->second->getIP()] < 5) {
               real++;
           }
       } else {
           listIP[it->second->getIP()] = 1;
           real++;
       }
   }
}
sprintf(buffer, "%d", real);
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);

Error:
 
Joined
Jan 8, 2017
Messages
50
Best answers
1
Likes
17
#94
Why? Have you tried to implement this to your engine before? Don't expect help if you even not try to do it by yourself.
 
Last edited:
Joined
Jan 8, 2017
Messages
50
Best answers
1
Likes
17
#98
Code:
uint32_t real = 0;
std::map<uint32_t, uint32_t> listIP;
for(AutoList<Player>::iterator it = Player::autoList.begin(); it != Player::autoList.end(); ++it) {
   if (it->second->getIP() != 0) {
        if (listIP.find(it->second->getIP()) != listIP.end()) {
             listIP[it->second->getIP()]++;
             if (listIP[it->second->getIP()] < 5) {
               real++;
             }
         } else {
           listIP[it->second->getIP()] = 1;
             real++;
         }
       }
}
sprintf(buffer, "%d", real);
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);
 
Joined
Dec 26, 2013
Messages
1,218
Best answers
4
Likes
370
#99
For server owners, maybe. Not for players.
Right! But now if all the owners switch, wtf do you think the players are gonna do?

@xinn
(I think you can get only 5-6 players from same IP) So this is not a problem.

Are you seriously mad. I have read and re-read, what you are suggesting is that all servers who want to use your site must sacrifice a possible percentage of their real players online credit.

If 5 players are online instead of 4 I would be pissed as fuck to see 4! That's a slap in the face to the developer when someone put their heart n soul into the server.

Just like previously stated, that kind of reply is like saying, well yeah the bug exists, but its hard to come by, no reason to fix it.
 
Joined
May 18, 2017
Messages
64
Best answers
0
Likes
8
I've created a working code you can implement in your server.

protocolstatus.cpp (TFS 1.0/1.1/1.2)
Someone can do it for 8.6

@xinn @Sir Knighter @Flatlander

Change:
Code:
players.append_attribute("online") = std::to_string(g_game.getPlayersOnline()).c_str();
To this:

Code:
uint32_t real = 0;

std::map<uint32_t, uint32_t> listIP;

for (const auto& it : g_game.getPlayers()) {
   if (it.second->getIP() != 0) {
      auto ip = listIP.find(it.second->getIP());
      if (ip != listIP.end()) {
         listIP[it.second->getIP()]++;
         if (listIP[it.second->getIP()] < 5) {
            real++;
         }
      } else {
         listIP[it.second->getIP()] = 1;
         real++;
      }
   }
}
players.append_attribute("online") = std::to_string(real).c_str();

PUMP

does it also fix isue of counting people that are X logged in the training arema ?
 
Top