• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Lua disabling drop loot for some vocations.

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
286
Solutions
6
Reaction score
92
Location
Egypt
Greetings, how do I disable the dropping loot for some vocations, and at the same time if they have red skull they lose their items? Using TFS 1.4.1
 
Solution
Splitted if into 2 parts. Moved vocation check after isRedOrBlack, so I can check, if player has red/black skull.
Lua:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) then
        return true
    end
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
    -- if does not have red/black skull and has special vocation
    if not isRedOrBlack and isInArray({2, 4, 6, 8}, player:getVocation():getId()) then
        return true
    end
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS and not isRedOrBlack then
        local isPlayer =...
OP
OP
Shalaby

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
286
Solutions
6
Reaction score
92
Location
Egypt
you mean player loot drop?
Yes I mean loot drop I can go this
Lua:
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or isInArray({2, 4, 6, 8}, player:getVocation():getId()) then
        return true
    end
But still, I don't know how to ignore this code in LUA because if I have a red skull the loot drop doesn't work however this is because of 'return true' I need to check if I have a red skull they also lose their items.
 
OP
OP
Shalaby

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
286
Solutions
6
Reaction score
92
Location
Egypt
can you copy the entire code please so I can check
replace with your droploot.lua
Lua:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) or isInArray({2, 4, 6, 8}, player:getVocation():getId()) 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
    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
 

Gesior.pl

Mega Noob&LOL 2012
Senator
Premium User
Joined
Sep 18, 2007
Messages
2,829
Solutions
91
Reaction score
2,974
Location
Poland
GitHub
gesior
Splitted if into 2 parts. Moved vocation check after isRedOrBlack, so I can check, if player has red/black skull.
Lua:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) then
        return true
    end
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
    -- if does not have red/black skull and has special vocation
    if not isRedOrBlack and isInArray({2, 4, 6, 8}, player:getVocation():getId()) then
        return true
    end
    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
 
Solution
OP
OP
Shalaby

Shalaby

Time has made me wiser, but no more patient.
Joined
Feb 17, 2011
Messages
286
Solutions
6
Reaction score
92
Location
Egypt
Splitted if into 2 parts. Moved vocation check after isRedOrBlack, so I can check, if player has red/black skull.
Lua:
function onDeath(player, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if player:hasFlag(PlayerFlag_NotGenerateLoot) then
        return true
    end
    local amulet = player:getSlotItem(CONST_SLOT_NECKLACE)
    local isRedOrBlack = table.contains({SKULL_RED, SKULL_BLACK}, player:getSkull())
    -- if does not have red/black skull and has special vocation
    if not isRedOrBlack and isInArray({2, 4, 6, 8}, player:getVocation():getId()) then
        return true
    end
    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
Thanks very much, Gesior this really helped me a lot.
 
Top