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

Drop item inside container - Rare, Epic and Legendary Loot Rolls

arthurluna

Member
Joined
Apr 12, 2008
Messages
178
Reaction score
12
I need help from someone experienced, this script works as follows, when I forget an item inside a Container, after a while the content is checked and returned to the main deposit, I can make it work, but after checking each position it returns nil for the situation.

when placing item in container 1, if the item is verified true, it continues to two, but I want you to do the verification in all positions and return the item for deposit

Lua:
    function abandonedItem(playerId, anvilorworkbench)
        local anvils = {Position(32272, 32186, 7), Position(32276, 32189, 7), Position(32279, 32187, 7), Position(32272, 32193, 7), Position(32275, 32198, 7), Position(32277, 32198, 7), Position(32272, 32200, 7), Position(32277, 32204, 7), Position(32275, 32204, 7)}
        local opticorder = {Position(32276, 32186, 7), Position(32272, 32189, 7), Position(32278, 32195, 7), Position(32273, 32202, 7)}
        local itemtosend = false
        for i = 1, #opticorder do     
            local optforge = Tile(opticorder[i]):getItemById(23571) --anvil
            if anvilorworkbench == "workbench" then
                if optforge:isContainer() then
                    itemtosend = optforge:getItem(0)
                    print("workbench "..i)
                    print("item to send "..itemtosend)
                end
            end
          
        for i = 1,  #anvils do     
            local anvilp = Tile(anvils[i]):getItemById(7843) --anvil
            if anvilorworkbench == "anvil" then
                if anvilp:isContainer() then
                    itemtosend = anvilp:getItem(0)
                    print("anvil "..i)
                    print(itemtosend)
                end
            end
      
        if itemtosend then
            local player = false
            -- see if player is online
            for _, playersearch in ipairs(Game.getPlayers()) do
                if playersearch:getId() == playerId then
                    player = Player(playerId)
                    print("player is online")
                end
            end
            -- player is online
            if player then
                local depot = player:getDepotChest(1, true)
                itemtosend:moveTo(depot)
                player:sendTextMessage(MESSAGE_INFO_DESCR, "You have left an item unattended in the " .. anvilorworkbench .. " in the forge, it has been sent to your depot I.")
                player:save()
                local resetstorage = 0
                if anvilorworkbench == "workbench" then
                    resetstorage = 30020
                elseif anvilorworkbench == "anvil" then
                    resetstorage = 30021
                end
                Game.setStorageValue(resetstorage, -1)
            else
                itemtosend:removeAttribute(ITEM_ATTRIBUTE_OWNER)
            end
        else
            return false
            -- Couldn't get item from anvil/forge for some reason
            end
        end
    end
end
 

Attachments

Last edited:
Back
Top