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

Lua don't drop all bag

Makin

New Member
Joined
Sep 17, 2018
Messages
37
Solutions
1
Reaction score
2
Hi, I do not know how to make all containers / backpacks so that only the selected ones would fall out
I know so much about this fragment of the script "if hasSkull or math.random(item:isContainer() and 100 or 1000) <= lossPercent then"
sorry for my English;)


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_RING)
    local hasSkull = isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull())
    if amulet and amulet.itemid == ITEM_AMULETOFLOSS 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

        if not isPlayer or not player:hasBlessing(6) then
            player:removeItem(ITEM_AMULETOFLOSS, 1, -1, false)
        end
    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

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

    return true
end
 
Last edited:
I would start by checking this
Code:
local lossPercent = player:getLossPercent()

You can simply do
Code:
print(lossPercent)

I've never used that function in TFS but depending on what it spits out, you would have to adjust the math.random range.
So if you want it to be 10% chance and its printing 10000, then you need to change the random range to 1, 100000 but if its printing 1000 then the range will be 1, 10000.

Currently your script is set to 1,100 for a container and 1,1000 for a normal item. I assume this implies that your lossPercent is 10% and the number it should be printing will be 100, if this is the case then all containers should drop 100% of the time and items 10%. If this is not happening then I would have to take a deeper look, and if this is not what you are after, then maybe I misunderstood your question :(.

Edit:
Just in case you haven't done this, if player:getLossPercent exists then I'm sure there is a function to setLossPercent. You might have to use that function (maybe on login?) to set the players lossPercent.
 
34411
I want to do it so that it does not fall out when I do not have an aol

i use this script but is still falls out
Lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if (getPlayerSlotItem(cid, 2).itemid == 2003) then
        doSetCreatureDropLoot(cid, false) 
    end
return true
end
 
In your current onDeath script you could just do:
Code:
if amulet.itemid == 2003 then
    return true
end
 
Back
Top