class Filtering : public PlayerScript
{
public:
Filtering() : PlayerScript("Filtering") { }
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg)
{
CheckMessage(player, type, lang, msg);
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player*)
{
CheckMessage(player, type, lang, msg);
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group*)
{
CheckMessage(player, type, lang, msg);
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild*)
{
CheckMessage(player, type, lang, msg);
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel*)
{
CheckMessage(player, type, lang, msg);
}
void CheckMessage(Player* player, uint32 type, uint32 lang, std::string& msg)
{
if (lang == LANG_ADDON || type == CHAT_MSG_ADDON)
return;
// Here I Want Check if player isnt on list, then return
std::string Message = "|cff66ff00[CHAT]|r [";
Message += player->GetName();
Message += "]: |cfffaeb00";
Message += msg;
SessionMap Sessions = sWorld->GetAllSessions();
for (SessionMap::iterator itr = Sessions.begin(); itr != Sessions.end(); ++itr)
if (Player* plr = itr->second->GetPlayer())
if (plr->GetReceiveMessage(SEE_CHAT) == true)
{
WorldPacket data(SMSG_SERVER_MESSAGE, 50);
data << uint32(3);
data << Message;
plr->GetSession()->SendPacket(&data);
}
}
};