• 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)...
as i remember first its ID Channel, second its message type, third is player and then last one its just a string that match a message,

Example:

Lua:
player:sendChannelMessage(9, TALKTYPE_CHANNEL_Y, player, "It Working!")

not in home so i can't confirm if its a true

you can check correct order in luascript.cpp of your server.

also in your example player open Channel ID 13, and you are sending message to ID 9
 
Last edited:
as i remember first its ID Channel, second its message type, third is player and then last one its just a string that match a message,

Example:

Lua:
player:sendChannelMessage(9, TALKTYPE_CHANNEL_Y, player, "It Working!")

not in home so i can't confirm if its a true

you can check correct order in luascript.cpp of your server.

also in your example player open Channel ID 13, and you are sending message to ID 9
I made the correction, look at the console

otland2.png


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()
 

Attachments

I made the correction, look at the console

View attachment 81919


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()
That looks exactly like it should :) however the function is called sendTextMessage as in player:sendTextMessage()

ex.. player:sendTextMessage(MESSAGE_INFO_DESCR, 'Hello’)
 
Last edited:
That looks exactly like it should :) however the function is called sendTextMessage as in player:sendTextMessage()

ex.. player:sendTextMessage(MESSAGE_INFO_DESCR, 'Hello’)
Do you have any idea how to "fix" this?
 
Lua:
player:sendChannelMessage(author, text, type, channelId)
And for the role of being a player, you use
Lua:
sendChannelMessage(channelId, type, message)

My problem is that the message does not appear in the channel, I don't know if there is a bug in the source that does not execute the function

If I use:
Code:
print(13, TALKTYPE_CHANNEL_R1, "It Working!")
The message appears in the console, but if I use
Lua:
sendChannelMessage(13, TALKTYPE_CHANNEL_R1, "It Working!")
This message does not send to the channel
Post automatically merged:

I tested the script below, but it doesn't work in OTClient, but prints appear in the console.

Lua:
local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:openChannel(13)
    
    -- // player:sendChannelMessage(author, text, type, channelId)
    player:sendChannelMessage(player, "test", TALKTYPE_CHANNEL_R1, 13)
    
    --// sendChannelMessage(channelId, type, message)
    sendChannelMessage(13, TALKTYPE_CHANNEL_R1, "It Working!")
    
    print(player, "test", TALKTYPE_CHANNEL_R1, 13)
    print(13, TALKTYPE_CHANNEL_R1, "It Working!")
    return true
end

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

Otland.png
 
Last edited:
Last time I experianced simillar issue with channel massages and it was more or less related to the OTClient handling as channel was not yet “initalized” on the client side thus the message was skipped and error was shown on the client’ console. Also there was issue while there was only one member on the channel, but that was connected with sendToAll (server) logic.

To check whether it’s same issue you can delay sending that message to the channel with addEvent after it gets open or simply check clients channel logic (terminal console)

Lua:
player:sendChannelMessage(author, text, type, channelId)

EDIT: I've checked that with OTCv8 and belows code and it works (but it's 8.6 downgrade, If I find some time I'll check on 7.7 too):
Lua:
player:openChannel(8)
player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 8)

TEST.gif
 
Last edited:
Last time I experianced simillar issue with channel massages and it was more or less related to the OTClient handling as channel was not yet “initalized” on the client side thus the message was skipped and error was shown on the client’ console. Also there was issue while there was only one member on the channel, but that was connected with sendToAll (server) logic.

To check whether it’s same issue you can delay sending that message to the channel with addEvent after it gets open or simply check clients channel logic (terminal console)

Lua:
player:sendChannelMessage(author, text, type, channelId)

EDIT: I've checked that with OTCv8 and belows code and it works (but it's 8.6 downgrade, If I find some time I'll check on 7.7 too):
Lua:
player:openChannel(8)
player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 8)

View attachment 81927
In my version there is no dice to test, could you send me a script with event?


Looking at my terminal, when I run the script, this error appears console OTClient

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)
 
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);
    msg.addString(text);
    writeToOutputBuffer(msg);
}
 
Solution
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);
    msg.addString(text);
    writeToOutputBuffer(msg);
}
Working brother, you are awesome, thank you, I love you!
 
why we keep wasting our time , with shitty otsses, they are free because we are testing this for the ppl who knows what they are doing ... we aint get a free server with working mechanics. we are testers...
Post automatically merged:

i bet that we waste our time asking an asking and devs just see the thread and fix it right away, with no intention to release the fix
 
why we keep wasting our time , with shitty otsses, they are free because we are testing this for the ppl who knows what they are doing ... we aint get a free server with working mechanics. we are testers...
Post automatically merged:

i bet that we waste our time asking an asking and devs just see the thread and fix it right away, with no intention to release the fix
This is open project, everyone can contribute and propose their changes. Speking of this particular downgrade it’s outdated and marked as archived:

This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Usualy such projects are good starting point but rather for Devs as maintaining such projects requires at least basics of C++, Lua and git. Anyone who ever worked as software developer is aware that there’s no conspiracy and introducing same bug over and over is a thing that can happen during codebase rework and code cleanup. Especially in such generic projects where you build rather an engine that provides set of an API’s to use by others in their project. Mechanics of the “game” also evolves so having retro mechanics reflected 1:1 is also something that only some retro freaks are implementing on their own.
It’s no longer download and run as there are lots of projects run by team of experienced devs.
 
Back
Top