• 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.2 how to create loot channel and delete loot from server-log

Seen some but its for 0.3 and 0.4 tfs
Do you want to delete
loot chanle?
Post automatically merged:

Do you want to delete
loot chanle?
Lua:
data/chatchannels/scripts add loot.lua
and past \/
function onSpeak(player, type, message)
    return false
end
goto chatchannels xml add\/
    <channel id="9" name="Loot" public="1" script="loot.lua" />
and goto creaturescripts/scripts and make loot.lua
and past \/
function onLogin(cid)
local player = Player(cid)
  player:openChannel(9)
  return true
end
goto creaturescripts xml add \/
    <event type="login" name="loot" script="loot.lua"/>
And goto creaturescripts/scripts/login.lua add\/
        player:registerEvent("loot")
 
Last edited:
Do you want to delete
loot chanle?
Post automatically merged:


Lua:
data/chatchannels/scripts add loot.lua
and past \/
function onSpeak(player, type, message)
    return false
end
goto chatchannels xml add\/
    <channel id="9" name="Loot" public="1" script="loot.lua" />
and goto creaturescripts/scripts and make loot.lua
and past \/
function onLogin(cid)
local player = Player(cid)
  player:openChannel(9)
  return true
end
goto creaturescripts xml add \/
    <event type="login" name="loot" script="loot.lua"/>
And goto creaturescripts/scripts/login.lua add\/
        player:registerEvent("loot")
Lol it creates just a channel but it misses source it needs to send loot info in this channel
 
If you want to do like he said, would be easy to make the channel dedicated to loot, then for the part where you get the loot, can be found in the event onDropLoot, not sure when that was added to tfs, so if you don't have that then I'm sorry, I think it would be best that way, but it could also be done in an onDeath or an onKill, any of those events, if you write the logic would be a bit of work, but simple really, just find the item names, and send to that channel, the method you would use would be
Lua:
player:sendChannelMessage(author, text, type, channelId)
so just use that in any of those events and make a string containing the message you want to send to the channel and send it with the above method
 
If you want to do like he said, would be easy to make the channel dedicated to loot, then for the part where you get the loot, can be found in the event onDropLoot, not sure when that was added to tfs, so if you don't have that then I'm sorry, I think it would be best that way, but it could also be done in an onDeath or an onKill, any of those events, if you write the logic would be a bit of work, but simple really, just find the item names, and send to that channel, the method you would use would be
Lua:
player:sendChannelMessage(author, text, type, channelId)
so just use that in any of those events and make a string containing the message you want to send to the channel and send it with the above method
So you mean editing dropcorpse.lua? this line
Lua:
killer:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))
?
 
So you mean editing dropcorpse.lua? this line
Lua:
killer:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))
?
yup, you could definitely edit that line and have it sendChannelMessage instead and would fit your intended purpose
 
So you mean editing dropcorpse.lua? this line
Lua:
killer:sendTextMessage(MESSAGE_INFO_DESCR, string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))
?
well, just Create a new Channel "Loot" then you can replace this line with this :
Lua:
sendChannelMessage(channelid, TALKTYPE_CHANNEL_O,string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))

replace channelid with the id you used at chatchannels.xml
 
well, just Create a new Channel "Loot" then you can replace this line with this :
Lua:
sendChannelMessage(channelid, TALKTYPE_CHANNEL_O,string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))

replace channelid with the id you used at chatchannels.xml
where is dropcorpse.lua? i reviewed latest forgottenserver and it does not have it there's only default_onDropLoot.lua
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(MESSAGE_INFO_DESCR, text)
                sendChannelMessage(11, TALKTYPE_CHANNEL_O,string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))
            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)
            sendChannelMessage(11, TALKTYPE_CHANNEL_O,string.format("Loot of %s: %s", monster:getName():lower(), next(lootItems) and table.concat(lootItems, ", ") or "nothing."))
        end
    end
end

ec:register()
but didn't worked
Code:
function onLogin(cid)
local player = Player(cid)
  player:openChannel(11)
  return true
end

Code:
--local STORAGEVALUE_LOOT = 8914
function onSpeak(player, type, message)
    local player = Player(corpse:getCorpseOwner())
    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
Code:
<channel id="11" name="Loot Channel" script="looter.lua" />
<event type="login" name="Looter" script="loot.lua"/>
 
Back
Top