[General] Implement CleanChat()

pull/249/merge
Koncord 8 years ago
parent 7b98f9f7ff
commit 3803535bd5

@ -22,12 +22,25 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(true);
}
void ScriptFunctions::CleanChat(unsigned short pid)
void ScriptFunctions::CleanChatByPid(unsigned short pid)
{
Player *player;
GET_PLAYER(pid, player,);
player->chatMessage.clear();
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
}
void ScriptFunctions::CleanChat()
{
for (auto player : *Players::getPlayers())
{
player.second->chatMessage.clear();
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player.second);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
}
}

@ -48,7 +48,7 @@ public:
static boost::any CallPublic(const char *name, ...) noexcept;
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
static void CleanChat(unsigned short pid);
static void CleanChatByPid(unsigned short pid);
static void CleanChat();
/**
@ -100,6 +100,8 @@ public:
{"SetServerPassword", ScriptFunctions::SetServerPassword},
{"SetRuleString", ScriptFunctions::SetRuleString},
{"SetRuleValue", ScriptFunctions::SetRuleValue},
{"CleanChatByPid", ScriptFunctions::CleanChatByPid},
{"CleanChat", ScriptFunctions::CleanChat},
POSITIONAPI,
CELLAPI,

@ -114,8 +114,17 @@ namespace mwmp
{
setVisible(true);
}
mHistory->addText(color+msg);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, msg.c_str());
if(msg.size() == 0)
{
clean();
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Chat cleaned");
}
else
{
mHistory->addText(color + msg);
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, msg.c_str());
}
}
void GUIChat::printOK(const std::string &msg)
@ -142,7 +151,7 @@ namespace mwmp
void GUIChat::clean()
{
mHistory->clearUserStrings();
mHistory->setCaption("");
}
void GUIChat::pressedChatMode()

Loading…
Cancel
Save