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

Solved Drop Loot (player) stopped working

trustjah

Newbie
Joined
Jan 22, 2009
Messages
124
Solutions
6
Reaction score
14
Location
Belgium
Hello Otlanders,

TFS1.2
So for the last 2 weeks i've been changing and adding things to my datapack and now all of a sudden my droploot script is throwing me an error. It worked before.
I'm quite clueless on what's causing this.

TiberrorOndeath.png


Lua:
function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, 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 isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) 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)
            if item then
                if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) or math.random(item:isContainer() and 100 or 1000) <= player:getLossPercent() then
                    item:moveTo(corpse)
                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

I have a backup folder where the error does not exist with the same code.

Thanks in advance.
Post automatically merged:

Update; Found out it's hiding inside my actions folder. Not sure where yet.
 
Last edited:
Solution
One of my actions scripts was in conflict with this droploot script!
always save backups.
Post automatically merged:

@Xikini Exactly.
I've been migrating some stuff and this one was actually preventing the droploot script from working

Lua:
dofile('data/modules/scripts/blessings/blessings.lua')
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    return Blessings.useCharm(player, item)
end

changed to


Code:
local config = {
    [11258] = {blessId = 4, text = 'The Spark of the Phoenix'},
    [11259] = {blessId = 2, text = 'The Embrace of Tibia'},
    [11260] = {blessId = 1, text = 'The Spiritual Shielding'},
    [11261] = {blessId = 3, text = 'The Fire of the Suns'},
    [11262] = {blessId = 5, text = 'The Wisdom of Solitude'}
}...
One of my actions scripts was in conflict with this droploot script!
always save backups.
Post automatically merged:

@Xikini Exactly.
I've been migrating some stuff and this one was actually preventing the droploot script from working

Lua:
dofile('data/modules/scripts/blessings/blessings.lua')
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    return Blessings.useCharm(player, item)
end

changed to


Code:
local config = {
    [11258] = {blessId = 4, text = 'The Spark of the Phoenix'},
    [11259] = {blessId = 2, text = 'The Embrace of Tibia'},
    [11260] = {blessId = 1, text = 'The Spiritual Shielding'},
    [11261] = {blessId = 3, text = 'The Fire of the Suns'},
    [11262] = {blessId = 5, text = 'The Wisdom of Solitude'}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local useItem = config[item.itemid]
    if not useItem then
        return true
    end

    if player:hasBlessing(useItem.blessId) then
        player:say('You already possess this blessing.', TALKTYPE_MONSTER_SAY)
        return true
    end

    player:addBlessing(useItem.blessId)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, useItem.text .. ' protects you.')
    player:getPosition():sendMagicEffect(CONST_ME_LOSEENERGY)
    item:remove(1)
    return true
end
 
Last edited:
Solution
Back
Top