diff --git a/src/otclient/net/protocolgame.h b/src/otclient/net/protocolgame.h index c9453cf7..f51d8918 100644 --- a/src/otclient/net/protocolgame.h +++ b/src/otclient/net/protocolgame.h @@ -54,6 +54,7 @@ public: void sendTurnEast(); void sendTurnSouth(); void sendTurnWest(); + void sendTalk(int channelType, const std::string& message, int channelId = 0, const std::string& receiver = ""); void sendAddVip(const std::string& name); void sendRemoveVip(int id); diff --git a/src/otclient/net/protocolgamesend.cpp b/src/otclient/net/protocolgamesend.cpp index d18663af..14fa9c81 100644 --- a/src/otclient/net/protocolgamesend.cpp +++ b/src/otclient/net/protocolgamesend.cpp @@ -158,6 +158,35 @@ void ProtocolGame::sendTurnWest() send(oMsg); } +void ProtocolGame::sendTalk(int channelType, const std::string& message, int channelId, const std::string& receiver) +{ + // Game.getProtocolGame():sendTalk(1, "lalala", 0, "ignore") + // TODO: MAKE SURE IT WAS AN USER EVENT AND NOT DIRECTLY FROM SCRIPT. + + if(message.length() > 255 && message.length() <= 0) + return; + + OutputMessage oMsg; + oMsg.addU8(Otc::ClientTalk); + + assert(channelType >= 0); + oMsg.addU8(channelType); + + switch(channelType) { + case Otc::SpeakPrivate: + case Otc::SpeakPrivateRed: + oMsg.addString(receiver); + break; + case Otc::SpeakChannelYellow: + case Otc::SpeakChannelRed: + oMsg.addU16(channelId); + break; + } + + oMsg.addString(message); + send(oMsg); +} + void ProtocolGame::sendAddVip(const std::string& name) { OutputMessage oMsg; diff --git a/src/otclient/otclientluafunctions.cpp b/src/otclient/otclientluafunctions.cpp index 186f893f..e3a4242d 100644 --- a/src/otclient/otclientluafunctions.cpp +++ b/src/otclient/otclientluafunctions.cpp @@ -49,6 +49,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassMemberFunction("cancelLogin", &ProtocolLogin::cancelLogin); g_lua.registerClass(); + g_lua.bindClassMemberFunction("sendTalk", &ProtocolGame::sendTalk); g_lua.registerClass(); g_lua.registerClass(); @@ -63,6 +64,7 @@ void OTClient::registerLuaFunctions() g_lua.bindClassStaticFunction("logout", std::bind(&Game::logout, &g_game, _1)); g_lua.bindClassStaticFunction("cancelLogin", std::bind(&Game::cancelLogin, &g_game)); g_lua.bindClassStaticFunction("isOnline", std::bind(&Game::isOnline, &g_game)); + g_lua.bindClassStaticFunction("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &UIWidget::create);