• 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 message is being sent to all players.

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
923
Solutions
6
Reaction score
155
Location
Nowhere
Hello

I have the 8.6 Nekiero server TFS 1.3.

I have found a loot channel script system for tfs 1.3 is working but like i have said before. When a player killS something, the message is being sent to the whole playerbase logged in.

can somebody tell me where is the issue ?

chatchannels/loot.lua
Code:
local STORAGEVALUE_LOOT = 8914
function onSpeak(player, type, message)
    return false
end

function onJoin(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 1)
    return true
end

function onLeave(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 0)
    return true
end

and at chatchannel.xml
Code:
<channel id="11" name="Loot" script="loot.lua" />

events/scripts/monsters.lua
Lua:
local STORAGEVALUE_LOOT = 8914
function Monster:onDropLoot(corpse)

    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                    sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                end
            end
        end
    else
        local text = ("Loot de %s: nada (devivo a baixa stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    end
end
 
You're using this
Code:
sendChannelMessage(channelId, type, message)

Instead of this
Code:
player:sendChannelMessage(author, text, type, channelId)

So it sends to all users that listen
 
You're using this
Code:
sendChannelMessage(channelId, type, message)

Instead of this
Code:
player:sendChannelMessage(author, text, type, channelId)

So it sends to all users that listen
in the script is not written in that way, but i tried this and didn't worked the looot message is being sent to all players

Lua:
if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                    sendChannelMessage(11, TALKTYPE_CHANNEL_O, text, author)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text, author)
 
or you didn't input the parameters right?
Code:
player:sendChannelMessage(player, text, MESSAGE_INFO_DESCR, 11)
 
or you didn't input the parameters right?
Code:
player:sendChannelMessage(player, text, MESSAGE_INFO_DESCR, 11)
Not sure but i didn't in the order as you said
i tried in your way, but with this the message wont even appear to no one
Lua:
 if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                sendChannelMessage(author, text, TALKTYPE_CHANNEL_O, 11)
                author, text, TALKTYPE_CHANNEL_O, 11
            else
                player:sendTextMessage(author, text, MESSAGE_INFO_DESCR, 11)
            end
Post automatically merged:

or you didn't input the parameters right?
Code:
player:sendChannelMessage(player, text, MESSAGE_INFO_DESCR, 11)
nope tested with it and the message wont appear either

this is the original monster.lua
Lua:
function Monster:onDropLoot(corpse)
    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()
        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    else
        local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end
 
Last edited:
up help not recieving message
Lua:
local STORAGEVALUE_LOOT = 8914
function Monster:onDropLoot(corpse)

    if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                if player:getStorageValue(STORAGEVALUE_LOOT) == 8914 then
                    sendChannelMessage(9, TALKTYPE_CHANNEL_O, text, owner)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text, owner)
                end
            end
        end
    else
        local text = ("Loot de %s: nada (devivo a baixa stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            if player:getStorageValue(STORAGEVALUE_LOOT) == 8914 then
                sendChannelMessage(9, TALKTYPE_CHANNEL_O, text, owner)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text, owner)
            end
        end
    end
end
 
I was like 5min looking for what was happening, and I realized that it was easier than they thought.
with replace this
Code:
sendChannelMessage(9, TALKTYPE_CHANNEL_O, text, owner)
To this
Lua:
player:sendChannelMessage("",""..text.."", TALKTYPE_CHANNEL_O, 11)
It would already be solved.
 
Last edited:
I was like 5min looking for what was happening, and I realized that it was easier than they thought.
with replace this
Code:
sendChannelMessage(9, TALKTYPE_CHANNEL_O, text, owner)
To this
Lua:
player:sendChannelMessage("","..text..", TALKTYPE_CHANNEL_O, 11)
It would already be solved.
tested and does not work the message are being sent to server log channel
chatchannels.xml
Lua:
<channel id="11" name="Loot Channel" public="0" script="looter.lua" />
chatchannels/looter.lua
Code:
local STORAGEVALUE_LOOT = 8914
function onSpeak(player, type, message)
    return false
end

function onJoin(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 1)
    return true
end

function onLeave(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 0)
    return true
end
data/eventallbacks/monster/default_ondroploot.lua
Code:
local ec = EventCallback

ec.onDropLoot = function(self, corpse)
     if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                    sendChannelMessage("","..text..", TALKTYPE_CHANNEL_O,11)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                end
            end
        end
    else
        local text = ("Loot de %s: nada (devivo a baixa stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                sendChannelMessage("","..text..", TALKTYPE_CHANNEL_O, 11)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    end
end

ec:register()
 
tested and does not work the message are being sent to server log channel
chatchannels.xml
Lua:
<channel id="11" name="Loot Channel" public="0" script="looter.lua" />
chatchannels/looter.lua
Code:
local STORAGEVALUE_LOOT = 8914
function onSpeak(player, type, message)
    return false
end

function onJoin(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 1)
    return true
end

function onLeave(player)
    player:setStorageValue(STORAGEVALUE_LOOT, 0)
    return true
end
data/eventallbacks/monster/default_ondroploot.lua
Code:
local ec = EventCallback

ec.onDropLoot = function(self, corpse)
     if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
        return
    end

    local player = Player(corpse:getCorpseOwner())
    local mType = self:getType()
    if not player or player:getStamina() > 840 then
        local monsterLoot = mType:getLoot()

        for i = 1, #monsterLoot do
            local item = corpse:createLootItem(monsterLoot[i])
            if not item then
                print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
            end
        end

        if player then
            local text = ("Loot de %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                    sendChannelMessage("","..text..", TALKTYPE_CHANNEL_O,11)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                end
            end
        end
    else
        local text = ("Loot de %s: nada (devivo a baixa stamina)"):format(mType:getNameDescription())
        local party = player:getParty()
        if party then
            party:broadcastPartyLoot(text)
        else
            if player:getStorageValue(STORAGEVALUE_LOOT) == 1 then
                sendChannelMessage("","..text..", TALKTYPE_CHANNEL_O, 11)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    end
end

ec:register()
Try it but without it being EventCallback, I'm sure it will work for you. The file is located at data/events/scripts/monster.lua
 
Back
Top