• 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!

TFS 1.X+ Loot Channel can't be done accurately?

Leo32

Getting back into it...
Joined
Sep 21, 2007
Messages
987
Solutions
14
Reaction score
532
We don't really have a way of sending messages to channels without an author, or speaker representing a string.
For example:

Lua:
local message = "Hello"
player:sendChannelMessage(player, message, TALKTYPE_CHANNEL_Y, channelId)
01:00 Benji: Hello

Lua:
player:sendChannelMessage("", message, TALKTYPE_CHANNEL_Y, channelId)
player:sendChannelMessage(nil, message, TALKTYPE_CHANNEL_Y, channelId)
player:sendChannelMessage(false, message, TALKTYPE_CHANNEL_Y, channelId)
01:01 : Hello

Whereas with server log messages you can clearly see when they're system messages:
Lua:
player:sendTextMessage(MESSAGE_LOOT, "Hello")
01:02: Hello

But it seems there isn't any way to send system messages to channels like that?
What are people doing to work around this? how are you getting dedicated loot channels looking right?

I noticed we don't even make use of the Loot Channel or the Network Protocol message that Tibia use?

So it should be do-able:
C++:
NetworkMessage msg;
msg.addByte(0xCF); // 207 Item looted, is this ByteArray for loot statistics or loot channel info (?)
 
Solution
As far as I know, sendTextMessage allows for a 3rd parameter being the channel Id
Lua:
player:sendTextMessage(33, "Test", 3)
As far as I know, sendTextMessage allows for a 3rd parameter being the channel Id
Lua:
player:sendTextMessage(33, "Test", 3)
 
Solution
Doesn't seem to be the case:

OOOOO found it:

So this works, but can be flakey depending on your client and can make it debug if you use a MESSAGE_TYPE incorrectly.
It looks like we use TALKTYPE_* and MESSAGE_* whereas on CIP's client they're the same thing with extra decode stuff on the client end.

Flash for example:
In the flash client only certain MESSAGE_XXXXXX types pass the channelId parameter on :

Debugs if you send extra bytes for the channelId if you use MESSAGE_LOOT, MESSAGE_INFO_DESC, 6,7,8 (All options can be found here).

MESSAGE_LOOT for example is hard-coded to send to the server log:
Has something to do with that?
Doesn't even read the channelId bytes?

MESSAGE_GUILD isn't hard-coded, passes the channelId parameter:

Can re-use this information when configuring OTClient to accept MESSAGE_LOOT (31) properly webclient plssssssssss
But for now I'll have to do hacky shit for a loot channel to work in flash:

Can't get it to use client-side color, or manually specify colour at all.
MESSAGE_GUILD, MESSAGE_PARTY_MANAGEMENT and MESSAGE_PARTY are white on the client side.

Loot channel messages for players:
Lua:
-- Print loot list to Server Log
        if owner then
            local loot_msg = "Loot of " .. self:getNameDescription() .. ": " .. corpse:getContentDescription()

            if owner:getParty() then
                owner:getParty():broadcastLoot(loot_msg)
            else
                owner:sendTextMessage(MESSAGE_GUILD, loot_msg, 9) -- Custom loot channel message
                owner:sendTextMessage(MESSAGE_LOOT, loot_msg)
            end
        end
    else
        local loot_msg = "Loot of " .. self:getNameDescription() .. ": nothing (due to low stamina)"

        if owner:getParty() then
            owner:getParty():broadcastLoot(loot_msg)
        else
            owner:sendTextMessage(MESSAGE_GUILD, loot_msg, 9) -- Custom loot channel message
            owner:sendTextMessage(MESSAGE_LOOT, loot_msg)
        end
    end

Loot channel messages for party members.
(my c++ is shit 🤡 )
C++:
void Party::broadcastPartyLoot(const std::string& loot)
{
    leader->sendTextMessage(MESSAGE_LOOT, loot);

    // Custom Part lootchannel message
    TextMessage lootchannel(MESSAGE_GUILD, loot);
    lootchannel.channelId = 9;
    leader->sendTextMessage(lootchannel);

    for (Player* member : memberList) {
        member->sendTextMessage(MESSAGE_LOOT, loot);
        // Custom Part lootchannel message
        member->sendTextMessage(lootchannel);
    }
}

Could probably just do it all in LUA and bypass/redo owner:getParty():broadcastLoot(loot_msg) and not do any source changes, but whatever.
 
Last edited:
Back
Top