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();
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();
sprintf(buffer, "%d", g_game.getPlayersOnline());
xmlSetProp(p, (const xmlChar*)"online", (const xmlChar*)buffer);
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);
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);
Ive been searching for what to change in my codes but cant find it anywhere..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.
Error:
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);
For server owners, maybe. Not for players.
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();
YesPUMP
does it also fix isue of counting people that are X logged in the training arema ?