Advertisement
NonSequitur

Untitled

Feb 5th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. local function playerRemoveItems(player, remove)
  2.     local lookup = {}
  3.     for k, v in ipairs(remove) do
  4.         lookup[v] = true
  5.     end
  6.  
  7.     local containers = {}
  8.  
  9.     for i = CONST_SLOT_HEAD, CONST_SLOT_AMMO do
  10.         local slotItem = player:getSlotItem(i)
  11.         if slotItem then
  12.             if lookup[slotItem:getId()] then
  13.                 slotItem:remove()
  14.             elseif slotItem:isContainer() then
  15.                 table.insert(containers, slotItem)
  16.             end
  17.         end
  18.     end
  19.  
  20.     while #containers > 0 do
  21.         local container = table.remove(containers, #containers)
  22.         for i = 0, container:getSize() - 1 do
  23.             local item = container:getItem(i)
  24.             if lookup[item:getId()] then
  25.                 item:remove()
  26.             elseif item:isContainer() then
  27.                 table.insert(containers, item)
  28.             end
  29.         end
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement