• 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+ Implement loot channel

johnsamir

Advanced OT User
Joined
Oct 13, 2009
Messages
847
Solutions
6
Reaction score
151
Location
Nowhere
Hello Community

i want to add a loot channel system made for tfs 1.x that i have found in other forum. the script is partially working, the problem is that the loot message is being sent to all player that have the loot channel opened.
that's the loot channel. is there a way to set it up like
player:getStorageValue only if it's the owner? or if player is owner

Lua:
local STORAGEVALUE_LOOT = 8914--agregado
function onSpeak(player, type, message)
    return false
end

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

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

this is the mosnter.lua file
Lua:
local STORAGEVALUE_LOOT = 8914 --agregado el original esta afuera.
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)
    if player:getStorageValue(STORAGEVALUE_LOOT) == 8914 then
                    sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
                else
                    player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                end
            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)
if player:getStorageValue(STORAGEVALUE_LOOT) == 8914 then
                sendChannelMessage(11, TALKTYPE_CHANNEL_O, text)
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            end
        end
    end
end

i tried changing the word "player" for "owner"in monster.lua but i was getting this error.
Code:
attempt to call global 'owner' (a nil value)
im not sure but it might be becasue i removed the part that check if a player is owner or not in sources, i did it to make it feel like in the old days when you could stole the loot from others
 
Last edited:
Back
Top