• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ TFS 1.5 7.72 Downgrade Nekiro - sendChannelMessage Not Working

Forkz

Well-Known Member
Joined
Jun 29, 2020
Messages
380
Solutions
1
Reaction score
89
Hi Otlanders,

Code:
https://github.com/nekiro/TFS-1.5-Downgrades/tree/7.72/src

I have a problem with this function, it is not working, I have already tested print() in the server console and it works, but when it comes to the sendChannelMessage function it is not working.



I am using this test script
Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(13)
    player:sendChannelMessage(13, TALKTYPE_CHANNEL_Y, player, "It Working!")
    player:sendChannelMessage(13, TALKTYPE_CHANNEL_O, player, "It Working!")
    print(13, TALKTYPE_CHANNEL_Y, player, "It Working!")
    print(13, TALKTYPE_CHANNEL_O, player, "It Working!")
    return true
end

--action:aid(45025)
action:id(2173)
action:register()

In otclient the channel opens, but the messages are not sent, I put a printout in the console and got results.

73489-64cb710e45ecbba5fe6216484bea13f4.png

Can someone help me?
 
Last edited:
Solution
Code:
ERROR: ProtocolGame parse message exception (47 bytes, 17 unread, last opcode is 0xaa (170), prev opcode is 0xac (172)): unknown message mode 0
Packet has been saved to packet.log, you can use it to find what was wrong. (Protocol: 772)
Okay it looks like there is a bug in sendChannelMessage

Change that to:
C++:
void ProtocolGame::sendChannelMessage(const std::string& author, const std::string& text, SpeakClasses type, uint16_t channel)
{
    NetworkMessage msg;
    msg.addByte(0xAA);
    msg.add<uint32_t>(0x00);
    msg.addString(author);
    msg.addByte(type);
    msg.add<uint16_t>(channel)...
Look. this is my question:

I want to do this in source.

send private message of player to all members of gm chat.

Actually I can do using this:

C++:
Player* gm_is_online = getPlayerByName("ADM Jhanes");

if (gm_is_online) {
        gm_is_online->sendToChannel(player, TALKTYPE_CHANNEL_Y, text, 42);
    }

But I wan't to send to all members of gm chat

Solved:

C++:
ChatChannel* channel = g_chat->getChannelById(42);
        if (channel) {
            channel->sendToAll("test", TALKTYPE_CHANNEL_Y);
        }
 
Back
Top