bool Commands::whoIsOnline(Creature* creature, const std::string &cmd, const std::string ¶m)
{
Player* player = creature->getPlayer();
if(player)
{
AutoList<Player>::listiterator it = Player::listPlayer.list.begin();
std::stringstream ss;
ss << "Players online:" << std::endl;
bool first = true;
if(g_config.getString(ConfigManager::SHOW_GAMEMASTERS_ONLINE) == "no")
{
while (it != Player::listPlayer.list.end())
{
if(!(*it).second->accessLevel || player->accessLevel)
{
ss << (first ? "" : ", ") << (*it).second->name << " [" << (*it).second->level << "]";
first = false;
}
++it;
}
}
else
{
while (it != Player::listPlayer.list.end())
{
ss << (first ? "" : ", ") << (*it).second->name << " [" << (*it).second->level << "]";
first = false;
++it;
}
}
ss << ".";
player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, ss.str());
}
return true;
}