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

C++ TFS 1.3

Itutorial

Excellent OT User
Joined
Dec 23, 2014
Messages
2,325
Solutions
68
Reaction score
999
Can anyone tell me why this doesn't work? Player should always lose backpack without AOL. Nothing else unless redskull.

Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        return true
    end
  
    if player:getLevel() < 50 then
        return true
    end
  
    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            if item then
                if not item:moveTo(corpse) then
                    item:remove()
                end
            end
        end
    else
        local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
        if item then
            if not item:moveTo(corpse) then
                item:remove()
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end
    return true
end

Player doesn't lose backpack is the problem.
Player is above level 50, no skull, no AOL, and isnt nogenloot
 
Last edited:
Can anyone tell me why this doesn't work? Player should always lose backpack without AOL. Nothing else unless redskull.

Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        return true
    end

    if player:getLevel() < 50 then
        return true
    end

    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            if item then
                if not item:moveTo(corpse) then
                    item:remove()
                end
            end
        end
    else
        local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
        if item then
            if not item:moveTo(corpse) then
                item:remove()
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end
    return true
end

Player doesn't lose backpack is the problem.
Player is above level 50, no skull, no AOL, and isnt nogenloot
Edited from original
Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end
    local lev = player:getLevel()
    if lev =< 50 then
        return true
    else
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not isRedOrBlack then
        local isPlayer = false
        if killer then
            if killer:isPlayer() then
                isPlayer = true
            else
                local master = killer:getMaster()
                if master and master:isPlayer() then
                    isPlayer = true
                end
            end
        end

        if not isPlayer or not player:hasBlessing(6) then
            player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        end
    else
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            local lossPercent = player:getLossPercent()
            if item then
                if isRedOrBlack or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                    if (isRedOrBlack or lossPercent ~= 0) and not item:moveTo(corpse) then
                        item:remove()
                    end
                end
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end
    return true
end
end

Edited you file
Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end
    if player:getLevel() < 50 then
            return true
    else
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        return true
    end

    if table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            if item then
                if not item:moveTo(corpse) then
                    item:remove()
                end
            end
        end
    else
        local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
        if item then
            if not item:moveTo(corpse) then
                item:remove()
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
    end
    return true
end
end

Check if work for you now :)
 
Problem was here. Item should of been backpack

Lua:
local backpack = player:getSlotItem(CONST_SLOT_BACKPACK)
        if item then
            if not item:moveTo(corpse) then
                item:remove()
            end
        end
    end

Thanks for trying to help.
 
Back
Top