• 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] Item wich gives bonus only if is inside on a specific container

Athenuz

Owlz!
Joined
Oct 1, 2015
Messages
234
Reaction score
27
Location
México
Hi,

I need a script for a item which gives bonus like HP/MANA or skills ONLY if it is inside of a Backpack of Holding.

Not sure how to make it work, something like the Claw of Noxius when equipped has a chance to do damage, i think that can be useful to make this script.

I hope someone be able to help me with this, thanks
 
Hi, thanks for your reply...

What information u need? i provided what was on my mind but ask and i say o.o
Do you want it to work for any "backpack of holding" within the player's inventory? Say what you really wanna do. Do you really want it to use on backpack of holdings? If its a special slot with a special container your intention it would be easier.

If that is really what you wanna do you can use something like this:

Code:
CONTAINER_BONUSID = 1987
ITEMCONDITIONS = {
    [2158] =     function ()
                    -- add remove condition
                end,
}
function Player:onMoveItem(item, count, fromPosition, toPosition)
    local moveitemid = item:getId()
    if ITEMCONDITIONS[moveitemid] then
        local guid = self:getGuid()
        if toPosition.x == CONTAINER_POSITION then
            if toPosition.y >= 64 then
                local container = self:getContainerById(toPosition.y-64)
                local topparent = container:getTopParent()
                local moveToItem = container:getItem(toPosition.z)
                if topparent and topparent:isPlayer() and topparent:getGuid() == self:getGuid() then
                    local itemid = container:getId()
                    if itemid == CONTAINER_BONUSID then
                        if container:getSize() < container:getCapacity() then
                            print("Moved item inside")
                        end
                    elseif moveToItem then
                        if moveToItem:getId() == CONTAINER_BONUSID then
                            print("Moved item inside")
                        end
                    end
                end
            else
                local citem = self:getSlotItem(toPosition.y)
                if citem and citem:getId() == CONTAINER_BONUSID then
                    local container = Container(citem:getUniqueId())
                    if container then
                        if container:getSize() < container:getCapacity() then
                            print("Moved item inside")
                        end
                    end
                end
            end
        end

        if fromPosition.x == CONTAINER_POSITION then
            if fromPosition.y >= 64 then
                local container = self:getContainerById(fromPosition.y-64)
                local topparent = container:getTopParent()
                if topparent and topparent:isPlayer() and topparent:getGuid() == self:getGuid() then
                    print("Moved item outside")
                end
            end
        end
    end
    return true
end
 
Last edited:
Do you want it to work for any "backpack of holding" within the player's inventory? Say what you really wanna do. Do you really want it to use on backpack of holdings? If its a special slot with a special container your intention it would be easier.

If that is really what you wanna do you can use something like this:

Code:
CONTAINER_BONUSID = 1987
ITEMCONDITIONS = {
    [2158] =     function ()
                    -- add remove condition
                end,
}
function Player:onMoveItem(item, count, fromPosition, toPosition)
    local moveitemid = item:getId()
    if ITEMCONDITIONS[moveitemid] then
        local guid = self:getGuid()
        if toPosition.x == CONTAINER_POSITION then
            if toPosition.y >= 64 then
                local container = self:getContainerById(toPosition.y-64)
                local topparent = container:getTopParent()
                local moveToItem = container:getItem(toPosition.z)
                if topparent and topparent:isPlayer() and topparent:getGuid() == self:getGuid() then
                    local itemid = container:getId()
                    if itemid == CONTAINER_BONUSID then
                        if container:getSize() < container:getCapacity() then
                            print("Moved item inside")
                        end
                    elseif moveToItem then
                        if moveToItem:getId() == CONTAINER_BONUSID then
                            print("Moved item inside")
                        end
                    end
                end
            else
                local citem = self:getSlotItem(toPosition.y)
                if citem and citem:getId() == CONTAINER_BONUSID then
                    local container = Container(citem:getUniqueId())
                    if container then
                        if container:getSize() < container:getCapacity() then
                            print("Moved item inside")
                        end
                    end
                end
            end
        end

        if fromPosition.x == CONTAINER_POSITION then
            if fromPosition.y >= 64 then
                local container = self:getContainerById(fromPosition.y-64)
                local topparent = container:getTopParent()
                if topparent and topparent:isPlayer() and topparent:getGuid() == self:getGuid() then
                    print("Moved item outside")
                end
            end
        end
    end
    return true
end

Hi, thanks for your quick reply!

Well, i was thinking on something like only at backpack of holding after getting it at quest and then, u can use some items to get bonus stats inside of it but i think your idea is better... How about specific container on the ring slot? The container will have like 1-20 slots, and inside the container, the items which gives bonus will work only inside of it..

As i understand this script, it's to activate the bonus of a item inside of the container but, how i add the bonus to each item i need? i got a bit confused..

Thanks for your help
 
Back
Top