Zeroun_Scripts

OTCv8 Reward Chest Reworked - Untested

Jul 14th, 2022 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. macro(300, "Loot reward bag", function()
  2.     local rewardChestId = 19250
  3.     local rewardBagId = 19202
  4.     local mainBp = 23721 --Change this to whatever bag you want and all loot bag need to be same id,
  5.                             --also use my open next backpack when full macro in conjunction with this one
  6.  
  7. -------------------DONT EDIT BELOW THIS LINE-------------------
  8. --Search for items in loot table above, move them to backpack
  9. local currentCap = freecap()
  10.     --If > 120 cap
  11.     if currentCap > 120 then
  12.         -- Search for all open containers
  13.         for i, container in pairs(getContainers()) do
  14.             containerItemId = container:getContainerItem():getId()
  15.             --If you find the reward bag
  16.             if containerItemId == rewardBagId then
  17.                 --For every item in reward bag
  18.                 for j, item in ipairs(container:getItems()) do
  19.                     local foundItem = item
  20.                     --Search for containers again
  21.                     for i, depotcontainer in pairs(getContainers()) do
  22.                         containerItemId = depotcontainer:getContainerItem():getId()
  23.                         --If you find your mainBp then
  24.                         if containerItemId == mainBp then
  25.                             --Get all the items in your mainBp to find slot positions
  26.                             for l, depotbox in ipairs(depotcontainer:getItems()) do
  27.                                 --print("moving item " .. foundItem:getId())
  28.                                 --print("before move " .. container:getItemsCount())
  29.                                 g_game.move(foundItem, depotcontainer:getSlotPosition(19), foundItem:getCount())
  30.                                 if container:getItemsCount() == 1 then
  31.                                     --g_game.openParent(container)
  32.                                     modules.client_entergame.CharacterList.doLogin()  
  33.                                 end
  34.                                 return
  35.                             end
  36.                         end
  37.                     end
  38.                 end
  39.             end
  40.         end
  41.     end
  42. end)
Add Comment
Please, Sign In to add comment