Core/Logging: Re-Implemented onChat scripting system

This commit is contained in:
Yehonal
2016-09-14 00:59:41 +02:00
parent c0590a5cfc
commit 3b2fb0949b
11 changed files with 303 additions and 4 deletions

View File

@@ -20,7 +20,7 @@ extern LoginDatabaseWorkerPool LoginDatabase;
Log::Log() :
raLogfile(NULL), logfile(NULL), gmLogfile(NULL), charLogfile(NULL),
dberLogfile(NULL), sqlLogFile(NULL), sqlDevLogFile(NULL), miscLogFile(NULL),
dberLogfile(NULL), chatLogfile(NULL), sqlLogFile(NULL), sqlDevLogFile(NULL), miscLogFile(NULL),
m_gmlog_per_account(false), m_enableLogDB(false), m_colored(false)
{
Initialize();
@@ -48,6 +48,10 @@ Log::~Log()
fclose(raLogfile);
raLogfile = NULL;
if (chatLogfile != NULL)
fclose(chatLogfile);
chatLogfile = NULL;
if (sqlLogFile != NULL)
fclose(sqlLogFile);
sqlLogFile = NULL;
@@ -87,6 +91,7 @@ void Log::Initialize()
m_dbChar = sConfigMgr->GetBoolDefault("LogDB.Char", false);
m_dbRA = sConfigMgr->GetBoolDefault("LogDB.RA", false);
m_dbGM = sConfigMgr->GetBoolDefault("LogDB.GM", false);
m_dbChat = sConfigMgr->GetBoolDefault("LogDB.Chat", false);
/// Realm must be 0 by default
SetRealmID(0);
@@ -137,6 +142,7 @@ void Log::Initialize()
charLogfile = openLogFile("CharLogFile", "CharLogTimestamp", "a");
dberLogfile = openLogFile("DBErrorLogFile", NULL, "a");
raLogfile = openLogFile("RaLogFile", NULL, "a");
chatLogfile = openLogFile("ChatLogFile", "ChatLogTimestamp", "a");
sqlLogFile = openLogFile("SQLDriverLogFile", NULL, "a");
sqlDevLogFile = openLogFile("SQLDeveloperLogFile", NULL, "a");
miscLogFile = fopen((m_logsDir+"Misc.log").c_str(), "a");
@@ -922,6 +928,33 @@ void Log::outCharDump(const char * str, uint32 account_id, uint32 guid, const ch
}
}
void Log::outChat(const char * str, ...)
{
if (!str)
return;
if (m_enableLogDB && m_dbChat)
{
va_list ap2;
va_start(ap2, str);
char nnew_str[MAX_QUERY_LEN];
vsnprintf(nnew_str, MAX_QUERY_LEN, str, ap2);
outDB(LOG_TYPE_CHAT, nnew_str);
va_end(ap2);
}
if (chatLogfile)
{
outTimestamp(chatLogfile);
va_list ap;
va_start(ap, str);
vfprintf(chatLogfile, str, ap);
fprintf(chatLogfile, "\n");
fflush(chatLogfile);
va_end(ap);
}
}
void Log::outRemote(const char * str, ...)
{
if (!str)

View File

@@ -123,6 +123,7 @@ class Log
void outErrorDb(const char * str, ...) ATTR_PRINTF(2, 3);
void outChar(const char * str, ...) ATTR_PRINTF(2, 3);
void outCommand(uint32 account, const char * str, ...) ATTR_PRINTF(3, 4);
void outChat(const char * str, ...) ATTR_PRINTF(2, 3);
void outRemote(const char * str, ...) ATTR_PRINTF(2, 3);
void outSQLDriver(const char* str, ...) ATTR_PRINTF(2, 3);
void outMisc(const char * str, ...) ATTR_PRINTF(2, 3); // pussywizard
@@ -151,6 +152,7 @@ class Log
FILE* gmLogfile;
FILE* charLogfile;
FILE* dberLogfile;
FILE* chatLogfile;
FILE* sqlLogFile;
FILE* sqlDevLogFile;
FILE* miscLogFile;
@@ -182,6 +184,7 @@ class Log
bool m_dbChar;
bool m_dbRA;
bool m_dbGM;
bool m_dbChat;
bool m_charLog_Dump;
bool m_charLog_Dump_Separate;
std::string m_dumpsDir;

View File

@@ -20422,6 +20422,9 @@ void Player::StopCastingCharm()
void Player::Say(const std::string& text, const uint32 language)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_SAY, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_SAY, Language(language), this, this, text);
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY), true);
@@ -20429,6 +20432,9 @@ void Player::Say(const std::string& text, const uint32 language)
void Player::Yell(const std::string& text, const uint32 language)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_YELL, language, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_YELL, Language(language), this, this, text);
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL), true);
@@ -20436,6 +20442,9 @@ void Player::Yell(const std::string& text, const uint32 language)
void Player::TextEmote(const std::string& text)
{
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_EMOTE, LANG_UNIVERSAL, _text);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_EMOTE, LANG_UNIVERSAL, this, this, text);
SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHAT));
@@ -20450,6 +20459,9 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver)
Player* rPlayer = ObjectAccessor::GetObjectInOrOutOfWorld(receiver, (Player*)NULL);
std::string _text(text);
sScriptMgr->OnPlayerChat(this, CHAT_MSG_WHISPER, language, _text, rPlayer);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_WHISPER, Language(language), this, this, text);
rPlayer->GetSession()->SendPacket(&data);

View File

@@ -137,6 +137,18 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
recvData.rfinish();
return;
}
if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
{
std::string msg = "";
recvData >> msg;
if (msg.empty())
return;
sScriptMgr->OnPlayerChat(sender, uint32(CHAT_MSG_ADDON), lang, msg);
}
break;
default:
sLog->outError("Player %s (GUID: %u) sent a chatmessage with an invalid language/message type combination",
@@ -373,6 +385,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (type == CHAT_MSG_PARTY_LEADER && !group->IsLeader(sender->GetGUID()))
return;
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
ChatHandler::BuildChatPacket(data, ChatMsg(type), Language(lang), sender, NULL, msg);
group->BroadcastPacket(&data, false, group->GetMemberGroup(GetPlayer()->GetGUID()));
@@ -383,6 +397,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
{
if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
{
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
guild->BroadcastToGuild(this, false, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
}
}
@@ -393,6 +409,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
{
if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
{
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
guild->BroadcastToGuild(this, true, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
}
}
@@ -408,6 +426,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
return;
}
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID, Language(lang), sender, NULL, msg);
group->BroadcastPacket(&data, false);
@@ -423,6 +443,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
return;
}
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_LEADER, Language(lang), sender, NULL, msg);
group->BroadcastPacket(&data, false);
@@ -433,6 +455,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
return;
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
//in battleground, raid warning is sent only to players in battleground - code is ok
ChatHandler::BuildChatPacket(data, CHAT_MSG_RAID_WARNING, Language(lang), sender, NULL, msg);
@@ -445,6 +469,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (!group || !group->isBGGroup())
return;
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND, Language(lang), sender, NULL, msg);
group->BroadcastPacket(&data, false);
@@ -456,6 +482,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
if (!group || !group->isBGGroup() || !group->IsLeader(GetPlayer()->GetGUID()))
return;
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_BATTLEGROUND_LEADER, Language(lang), sender, NULL, msg);
group->BroadcastPacket(&data, false);
@@ -475,6 +503,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
{
if (Channel* chn = cMgr->GetChannel(channel, sender))
{
sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
chn->Say(sender->GetGUID(), msg.c_str(), lang);
}
}
@@ -499,6 +529,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
sender->ToggleAFK();
}
sScriptMgr->OnPlayerChat(sender, type, lang, msg);
}
break;
}
@@ -521,6 +553,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
sender->ToggleDND();
}
sScriptMgr->OnPlayerChat(sender, type, lang, msg);
break;
}
default:

View File

@@ -1213,6 +1213,31 @@ void ScriptMgr::OnPlayerDuelEnd(Player* winner, Player* loser, DuelCompleteType
FOREACH_SCRIPT(PlayerScript)->OnDuelEnd(winner, loser, type);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Player* receiver)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, receiver);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, group);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, guild);
}
void ScriptMgr::OnPlayerChat(Player* player, uint32 type, uint32 lang, std::string& msg, Channel* channel)
{
FOREACH_SCRIPT(PlayerScript)->OnChat(player, type, lang, msg, channel);
}
void ScriptMgr::OnPlayerEmote(Player* player, uint32 emote)
{
FOREACH_SCRIPT(PlayerScript)->OnEmote(player, emote);

View File

@@ -716,6 +716,17 @@ class PlayerScript : public ScriptObject
// Called when a duel ends
virtual void OnDuelEnd(Player* /*winner*/, Player* /*loser*/, DuelCompleteType /*type*/) { }
// The following methods are called when a player sends a chat message.
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Player* /*receiver*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Group* /*group*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Guild* /*guild*/) { }
virtual void OnChat(Player* /*player*/, uint32 /*type*/, uint32 /*lang*/, std::string& /*msg*/, Channel* /*channel*/) { }
// Both of the below are called on emote opcodes.
virtual void OnEmote(Player* /*player*/, uint32 /*emote*/) { }

View File

@@ -1188,6 +1188,17 @@ void World::LoadConfigSettings(bool reload)
m_int_configs[CONFIG_NUMTHREADS] = sConfigMgr->GetIntDefault("MapUpdate.Threads", 1);
m_int_configs[CONFIG_MAX_RESULTS_LOOKUP_COMMANDS] = sConfigMgr->GetIntDefault("Command.LookupMaxResults", 0);
// chat logging
m_bool_configs[CONFIG_CHATLOG_CHANNEL] = sConfigMgr->GetBoolDefault("ChatLogs.Channel", false);
m_bool_configs[CONFIG_CHATLOG_WHISPER] = sConfigMgr->GetBoolDefault("ChatLogs.Whisper", false);
m_bool_configs[CONFIG_CHATLOG_SYSCHAN] = sConfigMgr->GetBoolDefault("ChatLogs.SysChan", false);
m_bool_configs[CONFIG_CHATLOG_PARTY] = sConfigMgr->GetBoolDefault("ChatLogs.Party", false);
m_bool_configs[CONFIG_CHATLOG_RAID] = sConfigMgr->GetBoolDefault("ChatLogs.Raid", false);
m_bool_configs[CONFIG_CHATLOG_GUILD] = sConfigMgr->GetBoolDefault("ChatLogs.Guild", false);
m_bool_configs[CONFIG_CHATLOG_PUBLIC] = sConfigMgr->GetBoolDefault("ChatLogs.Public", false);
m_bool_configs[CONFIG_CHATLOG_ADDON] = sConfigMgr->GetBoolDefault("ChatLogs.Addon", false);
m_bool_configs[CONFIG_CHATLOG_BGROUND] = sConfigMgr->GetBoolDefault("ChatLogs.BattleGround", false);
// Warden
m_bool_configs[CONFIG_WARDEN_ENABLED] = sConfigMgr->GetBoolDefault("Warden.Enabled", false);
m_int_configs[CONFIG_WARDEN_NUM_MEM_CHECKS] = sConfigMgr->GetIntDefault("Warden.NumMemChecks", 3);

View File

@@ -132,6 +132,15 @@ enum WorldBoolConfigs
CONFIG_PVP_TOKEN_ENABLE,
CONFIG_NO_RESET_TALENT_COST,
CONFIG_SHOW_KICK_IN_WORLD,
CONFIG_CHATLOG_CHANNEL,
CONFIG_CHATLOG_WHISPER,
CONFIG_CHATLOG_SYSCHAN,
CONFIG_CHATLOG_PARTY,
CONFIG_CHATLOG_RAID,
CONFIG_CHATLOG_GUILD,
CONFIG_CHATLOG_PUBLIC,
CONFIG_CHATLOG_ADDON,
CONFIG_CHATLOG_BGROUND,
CONFIG_AUTOBROADCAST,
CONFIG_ALLOW_TICKETS,
CONFIG_DELETE_CHARACTER_TICKET_TRACE,

View File

@@ -567,6 +567,8 @@ void AddSC_outdoorpvp_tf();
void AddSC_outdoorpvp_zm();
void AddSC_outdoorpvp_gh();
// player
void AddSC_chat_log();
#endif
@@ -637,6 +639,7 @@ void AddWorldScripts()
AddSC_npcs_special();
AddSC_npc_taxi();
AddSC_achievement_scripts();
AddSC_chat_log();
#endif
}

View File

@@ -13,6 +13,7 @@ set(scripts_STAT_SRCS
${AC_SCRIPTS_DIR}/World/achievement_scripts.cpp
${AC_SCRIPTS_DIR}/World/areatrigger_scripts.cpp
${AC_SCRIPTS_DIR}/World/boss_emerald_dragons.cpp
${AC_SCRIPTS_DIR}/World/chat_log.cpp
${AC_SCRIPTS_DIR}/World/go_scripts.cpp
${AC_SCRIPTS_DIR}/World/guards.cpp
${AC_SCRIPTS_DIR}/World/item_scripts.cpp

View File

@@ -0,0 +1,157 @@
/*
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: http://github.com/azerothcore/azerothcore-wotlk/LICENSE-GPL2
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "ScriptMgr.h"
#include "Channel.h"
#include "Guild.h"
#include "Group.h"
class ChatLogScript : public PlayerScript
{
public:
ChatLogScript() : PlayerScript("ChatLogScript") { }
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg)
{
switch (type)
{
case CHAT_MSG_ADDON:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s sends: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_SAY:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[SAY] Player %s says (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
break;
case CHAT_MSG_EMOTE:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[TEXTEMOTE] Player %s emotes: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_YELL:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PUBLIC))
sLog->outChat("[YELL] Player %s yells (language %u): %s",
player->GetName().c_str(), lang, msg.c_str());
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 lang, std::string& msg, Player* receiver)
{
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_WHISPER))
sLog->outChat("[WHISPER] Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells %s: %s",
player->GetName().c_str(), receiver ? receiver->GetName().c_str() : "<unknown>", msg.c_str());
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Group* group)
{
//! NOTE:
//! LANG_ADDON can only be sent by client in "PARTY", "RAID", "GUILD", "BATTLEGROUND", "WHISPER"
switch (type)
{
case CHAT_MSG_PARTY:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY))
sLog->outChat("[PARTY] Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells group with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_PARTY_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_PARTY))
sLog->outChat("[PARTY] Leader %s tells group: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_RAID:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells raid with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_RAID_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Leader player %s tells raid: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_RAID_WARNING:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_RAID))
sLog->outChat("[RAID] Leader player %s warns raid with: %s",
player->GetName().c_str(), msg.c_str());
break;
case CHAT_MSG_BATTLEGROUND:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND))
sLog->outChat("[BATTLEGROUND] Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s tells battleground with leader %s: %s",
player->GetName().c_str(), group ? group->GetLeaderName() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_BATTLEGROUND_LEADER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_BGROUND))
sLog->outChat("[BATTLEGROUND] Leader player %s tells battleground: %s",
player->GetName().c_str(), msg.c_str());
break;
}
}
void OnChat(Player* player, uint32 type, uint32 lang, std::string& msg, Guild* guild)
{
switch (type)
{
case CHAT_MSG_GUILD:
if (lang != LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD))
sLog->outChat("[GUILD] Player %s tells guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
else if (lang == LANG_ADDON && sWorld->getBoolConfig(CONFIG_CHATLOG_ADDON))
sLog->outChat("[ADDON] Player %s sends to guild %s: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
break;
case CHAT_MSG_OFFICER:
if (sWorld->getBoolConfig(CONFIG_CHATLOG_GUILD))
sLog->outChat("[OFFICER] Player %s tells guild %s officers: %s",
player->GetName().c_str(), guild ? guild->GetName().c_str() : "<unknown>", msg.c_str());
break;
}
}
void OnChat(Player* player, uint32 /*type*/, uint32 /*lang*/, std::string& msg, Channel* channel)
{
bool isSystem = channel &&
(channel->HasFlag(CHANNEL_FLAG_TRADE) ||
channel->HasFlag(CHANNEL_FLAG_GENERAL) ||
channel->HasFlag(CHANNEL_FLAG_CITY) ||
channel->HasFlag(CHANNEL_FLAG_LFG));
if (sWorld->getBoolConfig(CONFIG_CHATLOG_SYSCHAN) && isSystem)
sLog->outChat("[SYSCHAN] Player %s tells channel %s: %s",
player->GetName().c_str(), channel->GetName().c_str(), msg.c_str());
else if (sWorld->getBoolConfig(CONFIG_CHATLOG_CHANNEL))
sLog->outChat("[CHANNEL] Player %s tells channel %s: %s",
player->GetName().c_str(), channel ? channel->GetName().c_str() : "<unknown>", msg.c_str());
}
};
void AddSC_chat_log()
{
new ChatLogScript();
}