Log in

View Full Version : Move Items from Mail (Inbox) to Main Backpack.



gimenezes
03-09-2016, 11:02 PM
I've tried all i saw here and google. No one code did the work. The maximum i had, was one that opened only.

I was planning something like in this line, i don't care to write 100, 200, 300 or 1000 lines, i only want to know how can i do

blah88
03-12-2016, 11:43 AM
Basically it will open your mainbp then open mailbox and start moving items from mailbox to backpack... So change it as you wish


local Inbox = nil
local DoNotHaveCap = true
local DontHasItem = true

while #Container.GetAll() ~= 0 do
Self.CloseContainers()
wait(300, 500)
end

Inbox = OpenMailBox()
Self.OpenMainBackpack()
local MainBP = Container.GetLast()

if Inbox:isOpen() and MainBP:isOpen() then

for slot = 0, Inbox:ItemCount()-1 do
local items = Inbox:GetItemData(slot)
while Self.Cap() >= Item.GetWeight(items.id) do
DontHasItem = true
DoNotHaveCap = true

if (Self.Cap() <= Item.GetWeight(items.id) or Item.GetWeight(items.id) == 0 ) then
DontHasItem = false

break
elseif (not MainBP:isFull()) and (inTable(NahBobItems, Item.GetName(items.id)) or inTable(HarounItems, Item.GetName(items.id)))then
if not Inbox:MoveItemToContainer(slot, MainBP:Index(), MainBP:ItemCapacity()-1, 100) then
DontHasItem = true
DoNotHaveCap = true

break
else
DontHasItem = false
DoNotHaveCap = false
end
end

if MainBP:isFull() then
for spot = 0, MainBP:ItemCount()-1 do
if Item.isContainer(MainBP:GetItemData(spot).id) then
MainBP:UseItem(spot, true)

DontHasItem = false
DoNotHaveCap = false
end
end
end

if DoNotHaveCap then
break
end
end

if DoNotHaveCap then
break
end
end
end

if DontHasItem then
print("All your items has been sold!\nTurning cavebot off...")

Cavebot.Stop()
end

function OpenMailBox()
local SELFPOS = Self.Position()
local SURROUNDINGS = {}
local DEPOTPOS = nil
local INITIALIZED = false
local inbox = nil

if INITIALIZED == false then

SURROUNDINGS[1] = { item = Map.GetTopUseItem( SELFPOS.x - 1, SELFPOS.y - 1, SELFPOS.z ), pos = { x = SELFPOS.x - 1, y = SELFPOS.y - 1, z = SELFPOS.z } }
SURROUNDINGS[2] = { item = Map.GetTopUseItem( SELFPOS.x - 1, SELFPOS.y , SELFPOS.z ), pos = { x = SELFPOS.x - 1, y = SELFPOS.y , z = SELFPOS.z } }
SURROUNDINGS[3] = { item = Map.GetTopUseItem( SELFPOS.x - 1, SELFPOS.y + 1, SELFPOS.z ), pos = { x = SELFPOS.x - 1, y = SELFPOS.y + 1, z = SELFPOS.z } }
SURROUNDINGS[4] = { item = Map.GetTopUseItem( SELFPOS.x, SELFPOS.y - 1, SELFPOS.z ), pos = { x = SELFPOS.x , y = SELFPOS.y - 1, z = SELFPOS.z } }
SURROUNDINGS[5] = { item = Map.GetTopUseItem( SELFPOS.x, SELFPOS.y + 1, SELFPOS.z ), pos = { x = SELFPOS.x , y = SELFPOS.y + 1, z = SELFPOS.z } }
SURROUNDINGS[6] = { item = Map.GetTopUseItem( SELFPOS.x + 1, SELFPOS.y - 1, SELFPOS.z ), pos = { x = SELFPOS.x + 1, y = SELFPOS.y - 1, z = SELFPOS.z } }
SURROUNDINGS[7] = { item = Map.GetTopUseItem( SELFPOS.x + 1, SELFPOS.y , SELFPOS.z ), pos = { x = SELFPOS.x + 1, y = SELFPOS.y , z = SELFPOS.z } }
SURROUNDINGS[8] = { item = Map.GetTopUseItem( SELFPOS.x + 1, SELFPOS.y + 1, SELFPOS.z ), pos = { x = SELFPOS.x + 1, y = SELFPOS.y + 1, z = SELFPOS.z } }

for i, tbl in pairs ( SURROUNDINGS ) do
if tbl.item.id == 3499 or tbl.item.id == 3498 or tbl.item.id == 3497 or tbl.item.id == 3496 or tbl.item.id == 3500 then
DEPOTPOS = tbl.pos
break
end
end

if DEPOTPOS ~= nil then
Self.BrowseField( DEPOTPOS.x, DEPOTPOS.y, DEPOTPOS.z )
wait( 500 )
Container.GetFirst():UseItem( 0, true)
wait( 500 )
Container.GetFirst():UseItem( 1, true)
wait( 500 )
wait( 500 )
INITIALIZED = true
end
end

if INITIALIZED == true then
inbox = Container.GetFirst()
return inbox
end
end

gimenezes
03-17-2016, 06:18 AM
Not working for me. Error at "Inbox = OpenMailBox()"