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

C++ [0.4] No count more then 4 players on same IP (NEW otservlist.org rulles)

willdu

Active Member
Joined
Mar 11, 2017
Messages
91
Reaction score
25
Now is not allowed count more then 4 players in the same IP on otservlist
Like you guys can see in this warning:
Very important - Rules change on otservlist.org

But i dont like the idea to block players to open more then 4 characters like xinn said in topic with IPTables
I would like to make source changes on 0.4 to dont count more then 4 players

A guy made this to 1.0,1.2...
https://otland.net/threads/very-important-rules-change-on-otservlist-org.247531/page-3#post-2407794

But me and a lot guys uses 0.4...
Anybody know how to make it work on 0.4?

bump
 
Last edited by a moderator:
How to NOT count x-logged players?

Not sure how true is that, but Don Daniello is trusted.

That is not what i asked for...
This code you send me do not count xlogged players (that i think already have on 0.4)
What i need is a script to the new otservlist rulles, can count only 4 players for IP, not more, not less

bump

bump

bump
 
Last edited by a moderator:
They create this rulles that i agree, but with no codes to work on this i can not open my server
A lot people uses 0.4, it should be fixed...

bump
 
Last edited by a moderator:
Here you are. (not tested)
Code:
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);

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:
Here you are. (not tested)
Code:
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);

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);

Could you adapt it on this status.cpp so i could know how to do in mine (because my looks like this)

 
Here you are. (not tested)
Code:
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);

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);
will this work on 0.3.6

I quess no. Send me status file and I'll implement.
 
Last edited by a moderator:
@Nevski.
I have a error(tfs 0.4). :(
8nfibw.png


What am I doing wrong?
My status.cpp: [C++] //////////////////////////////////////////////////////////////////////// // Ope - Pastebin.com
 

Thank you to trying help us on 0.4
But it's wont compiling bro

Errors:
hastebin

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);
 
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);
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);

It's compiling now, i think its working...
 
Back
Top