2016-01-12 03:41:44 +00:00
|
|
|
//
|
|
|
|
// Created by koncord on 29.04.16.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
|
|
|
|
#include <apps/openmw-mp/Networking.hpp>
|
|
|
|
#include <components/openmw-mp/NetworkMessages.hpp>
|
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
2017-01-25 15:19:53 +00:00
|
|
|
player->chatMessage = message;
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2016-11-17 16:35:30 +00:00
|
|
|
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "System: %s", message);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
|
2017-03-06 09:44:08 +00:00
|
|
|
|
2017-04-09 05:51:28 +00:00
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
|
2017-12-30 19:52:30 +00:00
|
|
|
|
2016-08-17 15:20:36 +00:00
|
|
|
if (broadcast)
|
2017-04-09 05:51:28 +00:00
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(true);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2017-06-12 00:01:23 +00:00
|
|
|
void ScriptFunctions::CleanChatByPid(unsigned short pid)
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-06-12 00:01:23 +00:00
|
|
|
Player *player;
|
|
|
|
GET_PLAYER(pid, player,);
|
|
|
|
|
|
|
|
player->chatMessage.clear();
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-06-12 00:01:23 +00:00
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
|
|
|
|
|
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 17:27:46 +00:00
|
|
|
void ScriptFunctions::CleanChat()
|
2016-01-12 03:41:44 +00:00
|
|
|
{
|
2017-06-12 00:01:23 +00:00
|
|
|
for (auto player : *Players::getPlayers())
|
|
|
|
{
|
|
|
|
player.second->chatMessage.clear();
|
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player.second);
|
2016-01-12 03:41:44 +00:00
|
|
|
|
2017-06-12 00:01:23 +00:00
|
|
|
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
|
|
|
|
}
|
2016-01-12 03:41:44 +00:00
|
|
|
}
|