hi
i cannot insert rows in unordered_map don't know why this don't work please correct me.
i have included typedef std::unordered_map<uint64, bool> PlayerList; in player.h
this is my code:
i cannot insert rows in unordered_map don't know why this don't work please correct me.
i have included typedef std::unordered_map<uint64, bool> PlayerList; in player.h
this is my code:
Code:
static bool AddInList(ChatHandler* handler, char const* args)
{
char* Name = strtok((char*)args, " ");
char* Mode = strtok(NULL, " ");
if (!Name || !Mode)
return true;
Player* player = sObjectAccessor->FindPlayerByName(Name);
std::string Handle = (char*)Mode;
PlayerList _PlayerList;
if (player && Handle == "on")
{
_PlayerList.insert(PlayerList::value_type(player->GetGUID(), true));
ChatHandler(handler->GetSession()).PSendSysMessage("INSERT");
}
else
{
_PlayerList.erase(player->GetGUID());
ChatHandler(handler->GetSession()).PSendSysMessage("ERASE");
}
return true;
}
static bool ShowList(ChatHandler* handler, char const* args)
{
PlayerList _PlayerList;
for (PlayerList::iterator itr = _PlayerList.begin(); itr != _PlayerList.end(); ++itr)
{
std::string Str = itr->first + " - " + itr->second;
ChatHandler(handler->GetSession()).PSendSysMessage("%s", Str);
}
return true;
}