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

CreatureEvent [OTX] [TFS 0.3 - 0.4] Death Channel (Based on gesior's death page)

Roddet

Staff member
Global Moderator
Joined
May 1, 2013
Messages
928
Solutions
101
Reaction score
748
Location
Mex
data/ibs/000-constant.lua add the following line:
Lua:
CHANNEL_DEATH = 10
data/XML/channels.xml
Lua:
<channel id="10" name="Deaths" logged="yes" active="0"/>

data/creaturescripts/
Lua:
--[[Script by Musztang]]
function isSummon(cid)
  return getCreatureMaster(cid) ~= nil and true or false
end

function onDeath(cid, corpse, deathList)
    i = 0
    str = getCreatureName(cid).." ["..getPlayerLevel(cid).."]"
    for _, pid in ipairs(deathList) do
        i = i + 1
        if (i == 1) then
            if(#deathList <= 1) then
                str = str.." was killed by "
            elseif(#deathList > 1 and #deathList <= 4) then
                str = str.." was slain by "
            elseif(#deathList > 4 and #deathList <= 7) then
                str = str.." was crushed by "
            elseif(#deathList > 7 and #deathList <= 10) then
                str = str.." was eliminated by "
            elseif(#deathList > 10) then
                str = str.." was annihilated by "
            end
        elseif (i == #deathList) then
            str = str.." and "
        else
            str = str..", "
        end

        if not(isPlayer(pid) or isMonster(pid)) then
            str = str.."a field item"
        elseif isSummon(pid) then
            str = str.."a "..getCreatureName(pid):lower().." summoned by "..(isPlayer(getCreatureMaster(pid)) and "" or "a ")..""..getCreatureName(getCreatureMaster(pid))
        elseif isPlayer(pid) then
            str = str..""..getCreatureName(pid)
        elseif isMonster(pid) then
            str = str.."a "..getCreatureName(pid):lower()
        end
    end
    str = str.."."

    for _, creature in ipairs(getChannelUsers(CHANNEL_DEATH)) do
        doPlayerSendChannelMessage(creature, '', str, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
    end
    return true
end

You can use something like this on Login.lua to open it automatically.
Lua:
doPlayerOpenChannel(cid, 10)
 
Last edited:
Whats is the line for creaturescripts.xml?
I tried
Code:
<event type="death" name="Deathchannel" script="deathchannel.lua"/>

and it did not work.

EDIT: I made it work.
 
Last edited:
Back
Top