• 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.X+ amulets of lose

abdala ragab

Veteran OT User
Joined
Aug 18, 2018
Messages
593
Solutions
17
Reaction score
440
Location
gamelaots.online
Help me fix this text Every amulet doesn't get lost when you die and items don't fall if you don't have aol
I think I ruined it xD
I want this to work like a system Aol local amulets = {2173, 2138, 2218}
This amulet is forever local forevers = {2196, 7890}

Lua:
local amulets = {2173, 2138, 2218}
local forevers = {2196, 7890}

function onDeath(player, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if getPlayerFlagValue(player, PlayerFlag_NotGenerateLoot) then
        return true
    end
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local hasSkull = isInArray({SKULL_RED}, player:getSkull())
    if amulet and (amulet and isInArray(amulets, amulet.itemid)) and (amulet and isInArray(forevers, amulet.itemid)) and not hasSkull 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
        local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
        if (amulet and isInArray(amulets, amulet.itemid)) then
        if not isPlayer or not player:hasBlessing(6) then
            amulet:remove()
        elseif (amulet and isInArray(forevers, amulet.itemid)) then
    return true
        else
        local lossPercent = player:getLossPercent()
        for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
            local item = player:getSlotItem(i)
            if item then
                if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then
                    if not item:moveTo(corpse) then
                        item:remove()
                        end
                    end
                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
Post automatically merged:

@Itutorial @johnsamir
Help me with this text
 
Last edited:
Solution
Oh, yeah it should work like that....

Lua:
local amulets = {2173, 2138, 2218, 2196, 7890} -- Add ALL amulets (aol) in here --
local forevers = {2196, 7890} -- Add forever ones here. --

function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if getPlayerFlagValue(player, 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 isInArray(amulets, amulet.itemid) and not isRedOrBlack then
        local isPlayer = false
        if killer then
            if killer:isPlayer() then...
Add all amulets even the forever ones in amulets table

Lua:
local amulets = {2173, 2138, 2218, 2196, 7890}
local forevers = {2196, 7890}

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 isInArray(amulets, amulet.itemid) 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
            if not isInArray(forevers, amulet.itemid) then
                amulet:remove()
            end
        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
 
Add all amulets even the forever ones in amulets table

Lua:
local amulets = {2173, 2138, 2218, 2196, 7890}
local forevers = {2196, 7890}

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 isInArray(amulets, amulet.itemid) 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
            if not isInArray(forevers, amulet.itemid) then
                amulet:remove()
            end
        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
I don't understand what you mean
This text, if the player dies without aol, he does not lose any of the elements. I want to fix it
Post automatically merged:

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/droploot.lua:eek:nDeath
data/creaturescripts/scripts/droploot.lua:5: attempt to call method 'hasFlag' (a
nil value)
 
Last edited:
Oh, yeah it should work like that....

Lua:
local amulets = {2173, 2138, 2218, 2196, 7890} -- Add ALL amulets (aol) in here --
local forevers = {2196, 7890} -- Add forever ones here. --

function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if getPlayerFlagValue(player, 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 isInArray(amulets, amulet.itemid) 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
            if not isInArray(forevers, amulet.itemid) then
                amulet:remove()
            end
        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
 
Last edited:
Solution
local forevers = {2196, 7890}
forever aol no work if i have this aol^ lose items :D

local amulets = {2173, 2138, 2218} << work fine good job
Post automatically merged:

<item id="7890" name="Forever Aol">
<attribute key="weight" value="220"/>
<attribute key="description" value="+50 health/ 50 mana every second. +4% magic damage."/>
<attribute key="slotType" value="necklace"/>
<attribute key="magiclevelpoints" value="4"/>
<attribute key="manaGain" value="50"/>
<attribute key="healthGain" value="50"/>

<item id="2196" article="a" name="Abdala Donate Amulet">
<attribute key="description" value="+100 health/ 100 mana every second. +7% magic damage."/>
<attribute key="weight" value="420"/>
<attribute key="slotType" value="necklace"/>
<attribute key="magiclevelpoints" value="7"/>
<attribute key="manaGain" value="100"/>
<attribute key="healthGain" value="100"/>
 
Oh I changed the table on accident.

Lua:
local amulets = {2173, 2138, 2218, 2196, 7890} -- Add ALL amulets (aol) in here --
local forevers = {2196, 7890} -- Add forever ones here. --

Fixed @lastpost
 
Back
Top