From 2090062c75763b936d9f0c8b16eafd9892415714 Mon Sep 17 00:00:00 2001 From: CPunch Date: Mon, 19 Apr 2021 14:40:29 -0500 Subject: [PATCH] Added Player:message() --- src/lua/PlayerWrapper.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lua/PlayerWrapper.cpp b/src/lua/PlayerWrapper.cpp index 0d20116..d9f32f0 100644 --- a/src/lua/PlayerWrapper.cpp +++ b/src/lua/PlayerWrapper.cpp @@ -5,6 +5,7 @@ #include "core/CNProtocol.hpp" #include "Player.hpp" #include "PlayerManager.hpp" +#include "Chat.hpp" #define LIBNAME "Player" #define PLRGONESTR "Player doesn't exist anymore, they left!" @@ -168,9 +169,21 @@ static int plr_teleport(lua_State *state) { return 0; } +static int plr_msg(lua_State *state) { + CNSocket *sock = grabSock(state, 1); + const char *msg = luaL_checkstring(state, 2); + + // sanity check + if (sock != NULL) + Chat::sendServerMessage(sock, std::string(msg)); + + return 0; +} + static const luaL_Reg plr_methods[] = { {"kick", plr_kick}, {"teleport", plr_teleport}, + {"message", plr_msg}, {0, 0} };