• 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

Active Member
Joined
Oct 13, 2009
Messages
232
Solutions
1
Reaction score
35
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
 

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,184
Solutions
22
Reaction score
2,345
Location
Poland
GitHub
Zbizu
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
 
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
232
Solutions
1
Reaction score
35
Location
Nowhere
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)
 

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,184
Solutions
22
Reaction score
2,345
Location
Poland
GitHub
Zbizu
or you didn't input the parameters right?
Code:
player:sendChannelMessage(player, text, MESSAGE_INFO_DESCR, 11)
 
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
232
Solutions
1
Reaction score
35
Location
Nowhere
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:
OP
OP
J

johnsamir

Active Member
Joined
Oct 13, 2009
Messages
232
Solutions
1
Reaction score
35
Location
Nowhere
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
 
Top