local removable = {1987, 1988, 5926, 7342, 5949, 2004, 2001, 2003, 2000, 2002, 1998, 10521, 10518, 10519}
function removeEmptyContainers(uid, ids)
local ret, i = 0, 0
while i < getContainerSize(uid) do
local v = getContainerItem(uid, i)
if isContainer(v.uid) then
if getContainerSize(v.uid) ~= 0 then
ret = ret + removeEmptyContainers(v.uid, removable)
if isInArray(removable, v.itemid) and getContainerSize(v.uid) == 0 then
i = i - 1
end
elseif isInArray(removable, v.itemid) then
doRemoveItem(v.uid)
i = i - 1
ret = ret + 1
end
end
i = i + 1
end
return ret
end
local config = {
exhaustionInSeconds = 30,
storage = 73209
}
function onSay(cid, words, param, channel)
if(exhaustion.check(cid, config.storage) == TRUE) then
doPlayerSendCancel(cid, "You can use this command once every " .. config.exhaustionInSeconds .. " seconds.")
return TRUE
end
local ret = 0
for i = 1, 10 do
local v = getPlayerSlotItem(cid, i).uid
if v > 0 and isContainer(v) then
ret = ret + removeEmptyContainers(v, removable)
end
end
ret = tostring(ret)
exhaustion.set(cid, config.storage, config.exhaustionInSeconds)
return doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, ret .. " empty container" .. (ret:sub(-1) == "1" and ret:sub(-2) ~= "11" and "" or "s") .. " removed.")
end