Sorry not sure how to fit it in coding hope this is what you need
lua code:
elseif (labelName == "ResetBps") then
delayWalker(2000)
setWalkerEnabled(false)
Container.Close(goldBP)
sleep(math.random(500, 1000))
Container.GetFirst():OpenChildren(goldBP)
sleep(math.random(500, 1000))
setWalkerEnabled(true)
function openBackpacks(...)
local backpacks = {...} -- List of backpacks to open.
local open = Container.GetIndexes() -- List of already open backpacks.
local main = Container.GetFirst() -- First open container is assumed to be main backpack (will be 0 if no container is open).
local toOpen = #backpacks -- Number of backpacks we need to open (used to check success).
local defaultOpen = {} -- A place to store the backpacks to open by container:OpenChildren(), if any.
local bps = {} -- A place to store the backpacks to open by container:UseItem(), if any. Why not always use :OpenChildren()? This way I can open bps by their relative position instead of id, so you don't have to worry about colours anymore.
if main:ID() == 0 then -- If no backpack is open, we need to open main.
if backpacks[1] ~= Self.Backpack().id then
toOpen = toOpen + 1
end
repeat -- Open main backpack.
wait(200, 600)
until Self.UseItemFromEquipment("backpack") > 0
wait(500)
main = Container.GetFirst()
end
for i = 1, #backpacks do
if type(backpacks[i]) == "table" then
if backpacks[i][1] > 16 then
if backpacks[i][2] ~= main:Index() then
main = Container.GetFromIndex(backpacks[i][2])
for spot = 0, main:ItemCount()-1 do
local item = main:GetItemData(spot)
if Item.isContainer(item.id) then
table.insert(bps, spot)
end
end
main:UseItem(bps[backpacks[i][1]])
wait(500, 900)
end
elseif backpacks[i][1] ~= main:ID() then
main = Container.GetFromIndex(backpacks[i][2])
main:OpenChildren(backpacks[i][1])
wait(500, 900)
end
elseif backpacks[i] < 16 then
if i == 1 then
for spot = 0, main:ItemCount()-1 do
local item = main:GetItemData(spot)
if Item.isContainer(item.id) then
table.insert(bps, spot)
end
end
for _, num in ipairs(backpacks) do
main:UseItem(bps[num])
wait(500, 900)
end
break
end
elseif backpacks[i] ~= main:ID() then
table.insert(defaultOpen, backpacks[i])
end
end
if #defaultOpen > 0 then
main:OpenChildren(unpack(defaultOpen))
end
wait(400)
if #open + toOpen == #Container.GetIndexes() then
return true
end
return false
end
function getOpenBackpacks()
local indexes = Container.GetIndexes() -- Find index for all open backpacks
local open = {} -- Create a place to store our open backpacks
for i = 1, #indexes do -- Search all open backpacks
tmpBP = Container.GetFromIndex(indexes[i])
table.insert(open, tmpBP:ID()) -- Store this backpack
end
return open -- Return found backpacks
end
function resetBackpacks(reset)
setWalkerEnabled(false)
local open = {} -- Create a table to hold backpack list
local close = {}
local indexes = Container.GetIndexes() -- Get ids of open backpacks.
if reset then
if reset > 0 and reset < #indexes then
for i = (#indexes-reset)+1, #indexes do
table.insert(open, indexes[i])
end
else
for i = 2, #indexes do -- If 'reset' is above the number of open backpacks we should reset all.
table.insert(open, indexes[i])
end
end
else
for i = 2, #indexes do -- If 'reset' is nil (empty argument) we should reset all backpacks.
table.insert(open, indexes[i])
end
end
local tries = 3 -- Give the script 3 tries to achieve a successful reset.
repeat
if reset then
if reset > 0 and reset < #indexes then
closeBackpacks(unpack(open)) -- Close selected backpacks
else
Self.CloseContainers() -- Close all backpacks.
end
else
Self.CloseContainers() -- Close all backpacks
end
wait(600, 800) -- wait a little while
local reopen = openBackpacks(unpack(open)) -- I store the return from openBackpacks, true if successfull, false otherwise
if tries == 0 then -- Check how many tries the function has left
print("BackpackReset failed!") -- Tell the user that reset has failed
return false
end
tries = tries - 1 -- One try has been spent
wait(100,200)
until reopen -- If reopen is true it means all backpacks were opened successfully and function is done
setWalkerEnabled(true)
return true
end