awok100
07-23-2016, 12:22 PM
Hi! I have a problem while trying to deposit items. As I've been botting when there were no depots in locker I cannot change my depositer to open Depot Boxes instead of backpacks. Here is the .lua code, i will appreciate any help.
elseif (labelName == "Depositing") then
--Opening depot & bps
Walker.Stop()
Self.ReachDepot()
wait(500,600)
Container.GetByName("Locker"):OpenChildren({3502, true}) -- Opens depot chest
wait(500,600)
Container.GetByName("Locker"):Close() -- Closes locker
wait(500,600)
--Depositing items
for i=0,5 do -- Repeat 4 times (put here amount of loot backpacks you have on yourself)
for j=Container.GetByName(LootBP):ItemCount()-1, 0, -1 do -- Checks all slot takens
local ItemName = Item.GetName(Container.GetByName(LootBP):GetItemDa ta(j).id):titlecase()
if table.contains(Items, ItemName) then -- If item is in Item list, move from loot backpack to depot bp)
Container.GetByName(LootBP):MoveItemToContainer(j, Container.GetByName(ItemsDepotBP):Index(), Container.GetByName(ItemsDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(ItemsDepotBP):isFull() then -- If depot backpack is filled open next
Dedi_OpenNextBp(ItemsDepotBP)
wait(200,400)
end
end
Dedi_OpenNextBp(LootBP) -- Checked all slots in current loot backpack, so open next and repeat looking for items again :)
wait(200,400)
end
--Depositing stackables
-- Here we have only 1 backpack, so we don't have to repeat it few times
for i=0,5 do
for j=Container.GetByName(StackBP):ItemCount()-1, 0, -1 do
local ItemName = Item.GetName(Container.GetByName(StackBP):GetItemD ata(j).id):titlecase()
if table.contains(Stackable, ItemName) then
Container.GetByName(StackBP):MoveItemToContainer(j , Container.GetByName(StackDepotBP):Index(), Container.GetByName(StackDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(StackDepotBP):isFull() then
Dedi_OpenNextBp(StackDepotBP)
wait(200,400)
end
end
Dedi_OpenNextBp(StackBP) -- Checked all slots in current loot backpack, so open next and repeat looking for items again :)
wait(200,400)
end
--Closing bps with items
Container.GetByName(ItemsDepotBP):Close()
wait(200,400)
Container.GetByName(StackDepotBP):Close()
wait(200,400)
Container.GetByName(StackBP):Close()
wait(200,400)
Container.GetByName(LootBP):Close()
wait(200,400)
Walker.Start()
end
end
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Self.ReachDepot = function (tries)
local tries = tries or 3
Walker.Stop()
local DepotIDs = {3497, 3498, 3499, 3500}
local DepotPos = {}
for i = 1, #DepotIDs do
local dps = Map.GetUseItems(DepotIDs[i])
for j = 1, #dps do
table.insert(DepotPos, dps[j])
end
end
local function gotoDepot()
local pos = Self.Position()
for i = 1, #DepotPos do
location = DepotPos[i]
Self.UseItemFromGround(location.x, location.y, location.z)
wait(1000, 2000)
if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
wait(1000, 1500)
if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
Walker.Start()
return true
end
else
print("Something is blocking the path. Trying next depot.")
end
end
return false
end
repeat
reachedDP = gotoDepot()
if reachedDP then
return true
end
tries = tries - 1
sleep(100)
print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
until tries <= 0
return false
end
Map.GetUseItems = function (id)
if type(id) == "string" then
id = Item.GetID(id)
end
local pos = Self.Position()
local store = {}
for x = -7, 7 do
for y = -5, 5 do
if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
table.insert(store, itemPos)
end
end
end
return store
end
-- Function to open bp inside backpack (all backpack must be same color!)
function Dedi_OpenNextBp(bp_name)
local backpack = Container.GetByName(bp_name)
for i = backpack:ItemCount()-1, 0, -1 do
local item = backpack:GetItemData(i).id
if (item == Item.GetID(bp_name)) then
backpack:UseItem(i, true)
end
end
end
-- Returns amount of backpack opened
function Dedi_WindowCount(CONTAINER_NAME)
local CONTAINER_NAME, WINDOW_COUNT, CONTAINER = tostring(CONTAINER_NAME or "all"):lower(), 0, Container.GetFirst()
while (CONTAINER:isOpen()) do
if (CONTAINER:Name():lower() == CONTAINER_NAME or CONTAINER_NAME == "all") then
WINDOW_COUNT = WINDOW_COUNT + 1
end
CONTAINER = CONTAINER:GetNext()
end
return WINDOW_COUNT
end
elseif (labelName == "Depositing") then
--Opening depot & bps
Walker.Stop()
Self.ReachDepot()
wait(500,600)
Container.GetByName("Locker"):OpenChildren({3502, true}) -- Opens depot chest
wait(500,600)
Container.GetByName("Locker"):Close() -- Closes locker
wait(500,600)
--Depositing items
for i=0,5 do -- Repeat 4 times (put here amount of loot backpacks you have on yourself)
for j=Container.GetByName(LootBP):ItemCount()-1, 0, -1 do -- Checks all slot takens
local ItemName = Item.GetName(Container.GetByName(LootBP):GetItemDa ta(j).id):titlecase()
if table.contains(Items, ItemName) then -- If item is in Item list, move from loot backpack to depot bp)
Container.GetByName(LootBP):MoveItemToContainer(j, Container.GetByName(ItemsDepotBP):Index(), Container.GetByName(ItemsDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(ItemsDepotBP):isFull() then -- If depot backpack is filled open next
Dedi_OpenNextBp(ItemsDepotBP)
wait(200,400)
end
end
Dedi_OpenNextBp(LootBP) -- Checked all slots in current loot backpack, so open next and repeat looking for items again :)
wait(200,400)
end
--Depositing stackables
-- Here we have only 1 backpack, so we don't have to repeat it few times
for i=0,5 do
for j=Container.GetByName(StackBP):ItemCount()-1, 0, -1 do
local ItemName = Item.GetName(Container.GetByName(StackBP):GetItemD ata(j).id):titlecase()
if table.contains(Stackable, ItemName) then
Container.GetByName(StackBP):MoveItemToContainer(j , Container.GetByName(StackDepotBP):Index(), Container.GetByName(StackDepotBP):ItemCapacity()-1)
wait(200,400)
end
if Container.GetByName(StackDepotBP):isFull() then
Dedi_OpenNextBp(StackDepotBP)
wait(200,400)
end
end
Dedi_OpenNextBp(StackBP) -- Checked all slots in current loot backpack, so open next and repeat looking for items again :)
wait(200,400)
end
--Closing bps with items
Container.GetByName(ItemsDepotBP):Close()
wait(200,400)
Container.GetByName(StackDepotBP):Close()
wait(200,400)
Container.GetByName(StackBP):Close()
wait(200,400)
Container.GetByName(LootBP):Close()
wait(200,400)
Walker.Start()
end
end
-------------------------------------------------------------------------
-------------------------------------------------------------------------
Self.ReachDepot = function (tries)
local tries = tries or 3
Walker.Stop()
local DepotIDs = {3497, 3498, 3499, 3500}
local DepotPos = {}
for i = 1, #DepotIDs do
local dps = Map.GetUseItems(DepotIDs[i])
for j = 1, #dps do
table.insert(DepotPos, dps[j])
end
end
local function gotoDepot()
local pos = Self.Position()
for i = 1, #DepotPos do
location = DepotPos[i]
Self.UseItemFromGround(location.x, location.y, location.z)
wait(1000, 2000)
if Self.DistanceFromPosition(pos.x, pos.y, pos.z) >= 1 then
wait(1000, 1500)
if Self.DistanceFromPosition(location.x, location.y, location.z) == 1 then
Walker.Start()
return true
end
else
print("Something is blocking the path. Trying next depot.")
end
end
return false
end
repeat
reachedDP = gotoDepot()
if reachedDP then
return true
end
tries = tries - 1
sleep(100)
print("Attempt to reach depot was unsuccessfull. " .. tries .. " tries left.")
until tries <= 0
return false
end
Map.GetUseItems = function (id)
if type(id) == "string" then
id = Item.GetID(id)
end
local pos = Self.Position()
local store = {}
for x = -7, 7 do
for y = -5, 5 do
if Map.GetTopUseItem(pos.x + x, pos.y + y, pos.z).id == id then
itemPos = {x = pos.x + x, y = pos.y + y, z = pos.z}
table.insert(store, itemPos)
end
end
end
return store
end
-- Function to open bp inside backpack (all backpack must be same color!)
function Dedi_OpenNextBp(bp_name)
local backpack = Container.GetByName(bp_name)
for i = backpack:ItemCount()-1, 0, -1 do
local item = backpack:GetItemData(i).id
if (item == Item.GetID(bp_name)) then
backpack:UseItem(i, true)
end
end
end
-- Returns amount of backpack opened
function Dedi_WindowCount(CONTAINER_NAME)
local CONTAINER_NAME, WINDOW_COUNT, CONTAINER = tostring(CONTAINER_NAME or "all"):lower(), 0, Container.GetFirst()
while (CONTAINER:isOpen()) do
if (CONTAINER:Name():lower() == CONTAINER_NAME or CONTAINER_NAME == "all") then
WINDOW_COUNT = WINDOW_COUNT + 1
end
CONTAINER = CONTAINER:GetNext()
end
return WINDOW_COUNT
end