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

tfs 1.5 8.6 nekiro - Where i can find function about red/black skull?

Dran Ryszard

Active Member
Joined
Apr 25, 2023
Messages
136
Reaction score
30
Location
Poland
Hi, i want make something, if player has something in bp or storage X = 1 then not drop items if had red/black skull, but i can't find in sources any word about loot drop if redskull or something, any ideas where i can find it?
 
Solution
LUA:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    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...
I believe You can implement it from here
creaturescripts\scripts/droploot
LUA:
local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
It depends on your idea. For example, if a player has an amulet, it won't drop items
I don't understand exactly what you want but this will help you
 
Last edited:
I believe You can implement it from here
creaturescripts\scripts/droploot
LUA:
local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
It depends on your idea. For example, if a player has an amulet, it won't drop items
I don't understand exactly what you want but this will help you

Okey, thanks. But where's any function about move/drop items to corpse if player has red/black skull?
I want add a animation + text after player died, and if player have X amulet equip (propably i will add few amulets) then not loses a BP with red/black skull and that amulet ofc


I was test and when player died only this is executable
LUA:
    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
        print("died and bag added")
    end

full code
LUA:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    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)
            print("died with 2")
        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()
                        print("died with 1")
                    end
                end
            end
        end
    end

    if not player:getSlotItem(CONST_SLOT_BACKPACK) then
        player:addItem(ITEM_BAG, 1, false, CONST_SLOT_BACKPACK)
        print("died and bag added")
    end
    return true
end
[/coe]


//edit
print died with 2 is executable if player died with amulet of loss equiped, but still not see any function about move/transfer/drop items to corps
 
LUA:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    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
    elseif player:getStorageValue(yourStorage) == 1 or player:getItemCount(yourItemId, itemAmount) then
        player:say('Protected', TALKTYPE_MONSTER_SAY)
        return true
    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

try
edit this to your stuff
LUA:
elseif player:getStorageValue(yourStorage) == 1 or player:getItemCount(yourItemId, itemAmount) then
 
LUA:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    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
    elseif player:getStorageValue(yourStorage) == 1 or player:getItemCount(yourItemId, itemAmount) then
        player:say('Protected', TALKTYPE_MONSTER_SAY)
        return true
    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

try
edit this to your stuff
LUA:
elseif player:getStorageValue(yourStorage) == 1 or player:getItemCount(yourItemId, itemAmount) then

Nah, not work :(
I was tried use ur ideas in few others lines etc But still not work.
In ur version it "PROTECTED" player everytime, if had amulet or not ;D
 
LUA:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or player:getVocation():getId() == VOCATION_NONE then
        return true
    end

    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
    end

    -- Prevent item loss only if player has red/black skull AND the storage or item
    if isRedOrBlack and (player:getStorageValue(yourStorage) == 1 or player:getItemCount(yourItemId) >= itemAmount) then
        player:say('Protected', TALKTYPE_MONSTER_SAY)
        return true
    end

    -- Normal item drop logic
    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

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