Advertisement
MrTralaR

PickUP Items Script

May 22nd, 2017
2,505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 KB | None | 0 0
  1. --[[
  2.     Free Itams
  3.     Version 2.0.0
  4.     By Mr Trala
  5. ]]
  6.  
  7. config = {
  8. -- Config for PickUP module.
  9.     itemID = {2854, 8828, 8829,
  10.     21747, 9697, 12803,
  11.     3154, 5785, 9222,
  12.     2856, 3580, 16129, 3232,
  13.     5785, 9586, 939,
  14.     20270, 2968, 5922,
  15.     942, 5953, 8764,
  16.     12724, 20138, 9586,
  17.     19216, 19218},   -- ItemIDs to be picked up
  18.     containerName = "backpack",  -- Ex. "Purple Backpack", "Backpack of holding", "Bag" etc
  19.     CheckPOS = 1 -- The SQM from your character to check if theres an item.
  20.    
  21. }
  22.  
  23. x = config
  24. function PickUP()
  25. local p = Self.Position()
  26. local Cont = Container.New(x.containerName)
  27.     if (Self.Cap() >= 1) then
  28.         for y = -x.CheckPOS, x.CheckPOS do
  29.             for x = -x.CheckPOS, x.CheckPOS do
  30.                 if table.contains(config.itemID, Map.GetTopUseItem(p.x + x, p.y + y, p.z).id) then
  31.                     Map.PickupItem(p.x+x, p.y+y, p.z, Cont:Index(), 0)
  32.                 end
  33.                
  34.                 if (Cont:ItemCount() == Cont:ItemCapacity()) then
  35.                         local openAt = Cont:ItemCount() - 1
  36.                     if (Item.isContainer(Cont:GetItemData(openAt).id)) then
  37.                         Cont:UseItem(openAt, true)
  38.                     end
  39.                 end
  40.             end
  41.         end
  42.     end
  43. end
  44.  
  45. registerEventListener(TIMER_TICK, "PickUP")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement