mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 16:25:35 +00:00
Re-add SendChatMessage
This commit is contained in:
parent
c2b73d93b5
commit
fd3088c78f
@ -142,3 +142,5 @@ std::string Comp(std::string Data);
|
|||||||
std::string DeComp(std::string Compressed);
|
std::string DeComp(std::string Compressed);
|
||||||
|
|
||||||
std::string GetPlatformAgnosticErrorString();
|
std::string GetPlatformAgnosticErrorString();
|
||||||
|
|
||||||
|
void LogChatMessage(const std::string& name, int id, const std::string& msg);
|
||||||
|
@ -128,3 +128,15 @@ std::string GetPlatformAgnosticErrorString() {
|
|||||||
return std::strerror(errno);
|
return std::strerror(errno);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LogChatMessage(const std::string& name, int id, const std::string& msg) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << "[CHAT] ";
|
||||||
|
if (id != -1) {
|
||||||
|
ss << "(" << id << ") <" << name << ">";
|
||||||
|
} else {
|
||||||
|
ss << name << "";
|
||||||
|
}
|
||||||
|
ss << msg;
|
||||||
|
Application::Console().Write(ss.str());
|
||||||
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "LuaAPI.h"
|
#include "LuaAPI.h"
|
||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
|
#include "Common.h"
|
||||||
#include "TLuaEngine.h"
|
#include "TLuaEngine.h"
|
||||||
|
|
||||||
static std::string LuaToString(const sol::object Value, size_t Indent = 1) {
|
static std::string LuaToString(const sol::object Value, size_t Indent = 1) {
|
||||||
@ -122,7 +123,7 @@ void LuaAPI::MP::DropPlayer(int ID, std::optional<std::string> MaybeReason) {
|
|||||||
void LuaAPI::MP::SendChatMessage(int ID, const std::string& Message) {
|
void LuaAPI::MP::SendChatMessage(int ID, const std::string& Message) {
|
||||||
std::string Packet = "C:Server: " + Message;
|
std::string Packet = "C:Server: " + Message;
|
||||||
if (ID == -1) {
|
if (ID == -1) {
|
||||||
//LogChatMessage("<Server> (to everyone) ", -1, Message);
|
LogChatMessage("<Server> (to everyone) ", -1, Message);
|
||||||
Engine->Network().SendToAll(nullptr, Packet, true, true);
|
Engine->Network().SendToAll(nullptr, Packet, true, true);
|
||||||
} else {
|
} else {
|
||||||
auto MaybeClient = GetClient(Engine->Server(), ID);
|
auto MaybeClient = GetClient(Engine->Server(), ID);
|
||||||
@ -130,7 +131,7 @@ void LuaAPI::MP::SendChatMessage(int ID, const std::string& Message) {
|
|||||||
auto c = MaybeClient.value().lock();
|
auto c = MaybeClient.value().lock();
|
||||||
if (!c->IsSynced())
|
if (!c->IsSynced())
|
||||||
return;
|
return;
|
||||||
//LogChatMessage("<Server> (to \"" + c->GetName() + "\")", -1, msg);
|
LogChatMessage("<Server> (to \"" + c->GetName() + "\")", -1, msg);
|
||||||
Engine->Network().Respond(*c, Packet, true);
|
Engine->Network().Respond(*c, Packet, true);
|
||||||
} else {
|
} else {
|
||||||
beammp_lua_error("SendChatMessage invalid argument [1] invalid ID");
|
beammp_lua_error("SendChatMessage invalid argument [1] invalid ID");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user