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

Death channel (with items player lost)

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
580
Solutions
2
Reaction score
58
Location
México
Hello otlanders, im trying to create a script that show the items the player loose when he dies. i could achieve something, but i have an issue with the function, it spams like this:
Tetete, arcanist level 128 was killed by a demon
Head Slot: strange helmet
Head Slot: strange helmet
Amulet Slot: Empty
Backpack Slot: pirate backpack
Head Slot: strange helmet
Amulet Slot: Empty
Backpack Slot: pirate backpack
Armor Slot: Empty
Right Hand: bag
Head Slot: strange helmet
Amulet Slot: Empty
Backpack Slot: pirate backpack
Armor Slot: Empty
Right Hand: bag
Left Hand: heroic axe
Head Slot: strange helmet
Amulet Slot: Empty

Script:
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).."]"
    str = getPlayerName(cid)..", "..getPlayerVocationName(cid).." level "..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 magic field"
        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

    local slotName = {"Head Slot", "Amulet Slot", "Backpack Slot", "Armor Slot", "Right Hand", "Left Hand", "Legs Slot", "Feet Slot", "Ring Slot", "Ammo Slot"}
    local player = getPlayerByNameWildcard(param)
    if isPlayer(cid) == true then
        local text = ""   
        for v=1, 10 do
            text = text.."\n"
            local item = getPlayerSlotItem(cid, v)
            if item.itemid > 0 then
                if isContainer(item.uid) == true then
                    -- text = text..slotName[v]..": "..getItemNameById(item.itemid)..getItemsInContainer(item, 1)
                    -- str = str.." (Full-Loot: "..text.."."
                else
                    text = text..slotName[v]..": "..getItemNameById(item.itemid)
                    str = str..text
                end
            else
                text = text..slotName[v]..": Empty"
                -- str = str.." (Full-Loot: "..text.."."
            end
        end
    end
    -- str = str.." (Full-Loot: "..text2.."."

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

im using tfs 0.4.3777
 
Back
Top