Zeroun_Scripts

OTCv8 Open Next Backpack When Empty

Nov 7th, 2020 (edited)
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. --If backpack is empty, this will open next backpack of same type
  2.     local mainBp = 8860 --Brocade BP use ID
  3.     --For every container open, get information on open containers
  4.     for i, container in pairs(getContainers()) do
  5.         --Get the IDs of every open container
  6.         containerItemId = container:getContainerItem():getId()
  7.         --If the containerItemID is equal to one of the open containers then
  8.         if containerItemId == mainBp then
  9.             --If the amount of items in the container is equal to 1 then
  10.             if container:getItemsCount() == 1 then
  11.                 --Search every item ID in the container
  12.                 for _, item in ipairs(container:getItems()) do
  13.                     --If one of the items in the container is equal to your backpack id, then
  14.                     if item:isContainer() then
  15.                         --Open up the backpack
  16.                         g_game.open(item, container)
  17.                     end
  18.                 end
  19.             end
  20.         end
  21.     end
Add Comment
Please, Sign In to add comment