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

Loot Channel Help

Polarbear72

Member
Joined
Mar 3, 2013
Messages
63
Solutions
1
Reaction score
5
Location
USA
This is my loot.lua script that ive been trying to get working for a independent loot channel. It doesn't actually show any loot in the channel and it also announces whenever any player joins the channel.

I just want it to show loot in this channel instead of server log and I want it to only show for the player not everyone in channel.

Any help is appreciated

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
    <channel id="2" name="Tutor" script="tutor.lua" />
    <channel id="3" name="World Chat" public="1" script="worldchat.lua" />
    <channel id="4" name="English Chat" public="1" script="englishchat.lua" />
    <channel id="5" name="Advertising" public="1" script="advertising.lua" />
    <channel id="6" name="Advertising-Rookgaard" public="1" script="advertising-rook.lua" />
    <channel id="7" name="Help" public="1" script="help.lua" />
    <channel id="8" name="Gamemaster" script="gamemaster.lua" />
    <channel id="9" name="Loot Channel" public="0" script="looter.lua" />
</channels>


Lua:
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 of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
                for _, member in ipairs(getPartyMembers(player)) do
                    doPlayerSendChannelMessage(member, player, text, TALKTYPE_CHANNEL_O, 9)
                end
            end
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                sendChannelMessage(9, TALKTYPE_CHANNEL_O, 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
            sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end

ec:register()
 
 
I changed default_ondroploot.lua to this and now it doesn't show loot drops anywhere

Lua:
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 of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
            else
                player:sendTextMessage("", text, TALKTYPE_CHANNEL_O, 9)
            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("", text, TALKTYPE_CHANNEL_O, 9)
        end
    end
end

ec:register()
 
please any help is appreciated

with the above script it no longer says loot in server log but now it says loot in local chat in yellow. I need this fixed so that it goes into the loot channel i created
 
Change
player:sendTextMessage("", text, TALKTYPE_CHANNEL_O, 9)
to
player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 9)
 
Solution
This is my loot.lua script that ive been trying to get working for a independent loot channel. It doesn't actually show any loot in the channel and it also announces whenever any player joins the channel.

I just want it to show loot in this channel instead of server log and I want it to only show for the player not everyone in channel.

Any help is appreciated

Lua:
<?xml version="1.0" encoding="UTF-8"?>
<channels>
    <channel id="2" name="Tutor" script="tutor.lua" />
    <channel id="3" name="World Chat" public="1" script="worldchat.lua" />
    <channel id="4" name="English Chat" public="1" script="englishchat.lua" />
    <channel id="5" name="Advertising" public="1" script="advertising.lua" />
    <channel id="6" name="Advertising-Rookgaard" public="1" script="advertising-rook.lua" />
    <channel id="7" name="Help" public="1" script="help.lua" />
    <channel id="8" name="Gamemaster" script="gamemaster.lua" />
    <channel id="9" name="Loot Channel" public="0" script="looter.lua" />
</channels>


Lua:
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 of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
            local party = player:getParty()
            if party then
                party:broadcastPartyLoot(text)
                for _, member in ipairs(getPartyMembers(player)) do
                    doPlayerSendChannelMessage(member, player, text, TALKTYPE_CHANNEL_O, 9)
                end
            end
            else
                player:sendTextMessage(MESSAGE_INFO_DESCR, text)
                sendChannelMessage(9, TALKTYPE_CHANNEL_O, 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
            sendChannelMessage(9, TALKTYPE_CHANNEL_O, text)
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
        end
    end
end

ec:register()
Works very good
I noticed that if I close loot channel the messages are being sent to the default channel and i want this to be handled via talkaction so
if a player has the channel open when he says !loot /loot channel will be close and if he ve the channel it will get open
by now i can simply close the channel by clicking on it, and i don't want that so
is there anybody willing to help me with this?

The messages are being sent to all the players
 
Last edited:
Works very good
hwo do i do to make the channel get opened at p´layers log in ? and how to make not possible to write in that channel?
To open channel when player logs:

go to creaturescripts/scripts/login.lua then add after
Lua:
if(lastLogin > 0) then
:

Lua:
doPlayerOpenChannel(cid, 12)

To make impossible to players write there, go to channels.xml and set active=0, like this:

Lua:
<channel id="12" name="Loot" active="0"/>
 
thanks it worked I noticed that if I close loot channel the messages are being sent to the default channel and i want this to be handled via talkaction so
if a player has the channel open when he says !loot /loot channel will be close and if he ve the channel it will get open
by now i can simply close the channel by clicking on it, and i don't want that so
is there anybody willing to help me with this?
 
I got this console message in OTX TFS 0.4:

ata/creaturescripts/scripts/lootchannel.lua:37: attempt to index local 'ec' (a nil value)
[7/3/2023 0:30:54] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/lootchannel.lua)
 
I got this console message in OTX TFS 0.4:

ata/creaturescripts/scripts/lootchannel.lua:37: attempt to index local 'ec' (a nil value)
[7/3/2023 0:30:54] [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/lootchannel.lua)
Its for tfs 1.x that have event callback
 
Back
Top