• 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 Doesn't work

Mitrixx

New Member
Joined
Sep 1, 2024
Messages
19
Reaction score
1
GitHub
Marski
Is there a way to make a loot channel so it won't be displaying at server log? I've been trying for 3 days but haven't done it yet..
I'm using TFS 1.2

configmanager.cpp
boolean[SHOW_MONSTER_LOOT] = getGlobalBoolean(L, "showMonsterLoot", true);
config.lua
showMonsterLoot = true

What's wrong with my code?
chatchannels.xml
LUA:
[CODE=lua]<?xml version="1.0" encoding="UTF-8"?>

<channels>

    <channel id="2" name="Rule Violations" script="ruleviolations.lua" />

    <channel id="3" name="Tutor" script="tutor.lua" />

    <channel id="4" name="Game Chat" public="1" script="worldchat.lua" />

    <channel id="5" name="Real Chat" public="1" script="englishchat.lua" />

    <channel id="6" name="Trade" public="1" script="trade.lua" />

    <channel id="7" name="Help" public="1" script="help.lua" />

    <channel id="8" name="Gamemaster" script="gamemaster.lua" />

    <channel id="9" name="TradeRook" public="1" script="traderook.lua" />

    <channel id="10" name="Loot Channel" public="0" script="loot.lua" />

</channels>
[/CODE]

loot.lua
Code:
-- Script for the loot channel
function onJoinChannel(player, channelId)
 
    return true
end

function onLeaveChannel(player, channelId)
  
    return true
end

creaturescripts.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
    <event type="login" name="PlayerLogin" script="login.lua"/>
    <event type="login" name="FirstItems" script="firstitems.lua"/>
    <event type="death" name="PlayerDeath" script="playerdeath.lua"/>
    <event type="kill" name="Task_Race" script="task_race.lua"/>
    <event type="kill" name="Task_Solo" script="task_solo.lua"/>
    <event type="kill" name="Boss_Kill" script="boss_kill.lua"/>
    <event type="login" name="Storage_Time_Login" script="storage_time_login.lua"/>
    <event type="think" name="Storage_Time_Real" script="storage_time_real.lua"/>
    <event type="advance" name="reward_level" script="reward_level.lua"/>
    <event type="kill" name="Minotaur_Mage_Rook" script="quests/minotaur_mage_rook.lua"/>
    <event type="kill" name="LootDropEvent" script="loot.lua"/>

</creaturescripts>

loot.lua in creaturescripts/scripts
LUA:
local lootEvent = {}

function lootEvent.onKill(player, target)
    local corpse = target:getCorpse()
    if not corpse then
        return true
    end

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

    local mType = target: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

        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(party:getMembers()) do
                member:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 10)
            end
        else
            player:sendTextMessage(MESSAGE_INFO_DESCR, text)
            player:sendChannelMessage("", text, TALKTYPE_CHANNEL_O, 10)
        end
    end
    return true
end


function onKill(player, target)
    return lootEvent.onKill(player, target)
end

monsters.cpp


LUA:
    if (g_config.getBoolean(ConfigManager::SHOW_MONSTER_LOOT)) {
        Player* owner = g_game.getPlayerByID(corpse->getCorpseOwner());
        if (owner && owner->isPremium()) {

            std::stringstream ss;
            ss << "Loot of " << nameDescription << ": " << corpse->getContentDescription() << ".";
            if (owner->getParty())
            {
                owner->getParty()->broadcastPartyLoot(ss.str());
            }
            else
            {
                owner->sendChannelMessage("", ss.str(), TALKTYPE_CHANNEL_Y, uint16_t(10)); // 12 to numer kanału lootu
            }
        }
    }

    corpse->startDecaying();
}
 
creaturescripts/scripts/loot.lua
LUA:
function onLogin(cid)
local player = Player(cid)
  player:openChannel(10)
  return true
end
creaturescripts/scripts/login.lua
Code:
player:registerEvent("loot")
chatchannels\scriptsloot.lua
Code:
function onSpeak(player, type, message)
    return false
end
chatchannels.xml
XML:
<channel id="10" name="Loot" public="1" script="loot.lua" />
Post automatically merged:

creaturescripts.xml
XML:
<event type="login" name="loot" script="loot.lua"/>
 
Doesn't it only add loot channel when you log in?
Or I don't understand something brother
Post automatically merged:

Didn't help
 
Doesn't it only add loot channel when you log in?
Or I don't understand something brother
Post automatically merged:

Didn't help
+ data/global.lua
LUA:
-- AutoLoot config
    AUTO_LOOT_MAX_ITEMS = 5

    -- Reserved storage
    AUTOLOOT_STORAGE_START = 10000
    AUTOLOOT_STORAGE_END = AUTOLOOT_STORAGE_START + AUTO_LOOT_MAX_ITEMS
-- AutoLoot config end
Add it on top global.lua
 
+ data/global.lua
LUA:
-- AutoLoot config
    AUTO_LOOT_MAX_ITEMS = 5

    -- Reserved storage
    AUTOLOOT_STORAGE_START = 10000
    AUTOLOOT_STORAGE_END = AUTOLOOT_STORAGE_START + AUTO_LOOT_MAX_ITEMS
-- AutoLoot config end
Add it on top global.lua
But I don't have autoloot:(
My problem is that loot from monsters is in "server log" but I want it to be in "loot channel"
 
creaturescripts/scripts/loot.lua
function onLogin(cid) local player = Player(cid) player:openChannel(10) return true endcreaturescripts/scripts/login.lua
player:registerEvent("loot")chatchannels\scriptsloot.lua
function onSpeak(player, type, message) return false endchatchannels.xml
<channel id="10" name="Loot" public="1" script="loot.lua" /> Post automatically merged: Yesterday at 21:28
creaturescripts.xml
<event type="login" name="loot" script="loot.lua"/>
+ data/global.lua
-- AutoLoot config AUTO_LOOT_MAX_ITEMS = 5 -- Reserved storage AUTOLOOT_STORAGE_START = 10000 AUTOLOOT_STORAGE_END = AUTOLOOT_STORAGE_START + AUTO_LOOT_MAX_ITEMS -- AutoLoot config endAdd it on top global.lua
Add that and it will work
 
Back
Top