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

playerdeath/Channel Deaths

Gaber Zen

Well-Known Member
Joined
Apr 22, 2023
Messages
224
Reaction score
51
Location
Egypt
hello guy`s
Iam add Channel Deaths, but no work
Nolist Why?
some one can help me
Sourc (The Forgotten Server 0.4)

<event type="death" name="PlayerDeath" event="script" value="playerdeath.lua"/>
Lua:
function onDeath(cid, corpse, deathList)

local strings = {""}
local t, position = 1, 1

local deathType = "killed"
local toSlain, toCrushed, toEliminated = 3, 9, 15

    if #deathList >= toSlain and #deathList < toCrushed then
        deathType = "slain"
    elseif #deathList >= toCrushed and #deathList < toEliminated then
        deathType = "crushed"
    elseif #deathList >= toEliminated then
        deathType = "eliminated"
    end

    for _, pid in ipairs(deathList) do
        if isCreature(pid) == true then
            strings[position] = t == 1 and "" or strings[position] .. ", "
            strings[position] = strings[position] .. getCreatureName(pid) .. ""
            t = t + 1
        else
            strings[position] = t == 1 and "" or strings[position] .. ", "
            strings[position] = strings[position] .."a field item"
            t = t + 1
        end
    end

    for i, str in ipairs(strings) do
        if(str:sub(str:len()) ~= ",") then
            str = str .. "."
        end

        msg = getCreatureName(cid) .. " was " .. deathType .. " at level " .. getPlayerLevel(cid) .. " by " .. str
    end

    for _, oid in ipairs(getPlayersOnline()) do
        doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
    end
    return true
end
 

Attachments

your register event in login?
Code:
registerCreatureEvent(cid, "PlayerDeath")

your define CHANNEL_DEATH ?
example
\data\XML\channels.xml
Lua:
<channel id="10" name="Deaths" logged="yes" active="no"/>
playerdeath.lua
Code:
doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, 10)
 
Last edited:
why did u put it in login xd

delete
Lua:
doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, 10)
of login



playerdeath.lua
your define CHANNEL_DEATH ?
Code:
for _, oid in ipairs(getPlayersOnline()) do
        doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
    end

you no have define CHANNEL_DEATH ?
go \data\XML\channels.xml
add
Lua:
<channel id="10" name="Deaths" logged="yes" active="no"/>
now
go\data\creaturescripts\scripts\playerdeath.lua

renplace
Code:
doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
for

Code:
doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, 10)

or
add line 2
Code:
local CHANNEL_DEATH = 10
and preserves
Code:
doPlayerSendChannelMessage(oid, "Deaths", msg, TALKTYPE_CHANNEL_O, CHANNEL_DEATH)
 
Last edited:
Back
Top