local function scanContainer(cid, uid, list)
for k = (getContainerSize(uid) - 1), 0, -1 do
local tmp = getContainerItem(uid, k)
if (isInArray(list, tmp.itemid)) then
if isItemStackable(tmp.itemid) and (getPlayerItemCount(cid, tmp.itemid) > 0) then
doStack(cid, tmp.itemid, tmp.type)
else
local item = doCreateItemEx(tmp.itemid, tmp.type)
doPlayerAddItemEx(cid, item, true)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Looted ' .. tmp.type .. ' ' .. getItemNameById(tmp.itemid) .. '.')
doRemoveItem(tmp.uid)
elseif isContainer(tmp.uid) then
scanContainer(cid, tmp.uid, list)
end
end
end