Very important - Rules change on otservlist.org

MemsoriaOT

Member
Joined
Dec 16, 2015
Messages
174
Reaction score
1
Location
Poland
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
Reaction score
0
EDIT: Nevermind, Xinn already answered my email.
 
Last edited:

login12

void newbie scripter()
Joined
Feb 26, 2011
Messages
134
Reaction score
9
Location
Brazil
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?
 

MemsoriaOT

Member
Joined
Dec 16, 2015
Messages
174
Reaction score
1
Location
Poland
@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
Reaction score
8
Location
Brazil
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
 

Luka Trklja

Member
Joined
Jul 8, 2016
Messages
119
Reaction score
7
Location
Croatia
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...
 

swordman

Intermediate OT User
Joined
Jun 5, 2011
Messages
390
Reaction score
4
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?
 

willdu

Member
Joined
Mar 11, 2017
Messages
56
Reaction score
10
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.
 

Nevski.

Member
Joined
Jan 8, 2017
Messages
50
Reaction score
17
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:

Blade33711

Member
Joined
Aug 6, 2012
Messages
133
Reaction score
0
Location
Poland
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:
 

Nevski.

Member
Joined
Jan 8, 2017
Messages
50
Reaction score
17
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:

Nevski.

Member
Joined
Jan 8, 2017
Messages
50
Reaction score
17
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);
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,216
Reaction score
372
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.
 

Yuggi

Member
Joined
May 18, 2017
Messages
64
Reaction score
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