Óbviamente, a função não é recursiva. Você tem que iterar sobre todos os containers para poder pegar todos os items.
Use essa função para pegar os items dentro do container:
function getItemsInContainer(uid) local items = {} if isContainer(uid) and getContainerSize(uid) > 0 then for slot=0, (getContainerSize(uid)-1) do local item = getContainerItem(uid, slot) if isContainer(item.uid) then local _items = getItemsInContainerById(item.uid) for i=0, #_items do table.insert(items, items[i]) end else table.insert(items, item) end end end return items end
Irá lhe retornar uma tabela com todos os items dentro do container, exceto containers(não fazem diferença pro seu caso).
Dai tu pode iterar sobre ela verificando pelo itemid.
local items = getItemsInContainer(corpse) for _, thing in pairs(items) do if isInArray(config.ids, thing.itemid) then if config.drop_effect then doSendMagicEffect(position, 55, cid) end end end





info
Grupo: Artesão
Registrado: 06/02/13
Posts: 132
Reputação: +8
Char no Tibia: Koete
Como diz o Título, eu tenho um script que mostra um efeito em cima dos monstros quando dropa certos itens (configurável).
Sendo que ele só mostra o efeito se o item dropar no corpo, se ele dropar dentro de uma bag o efeito não aparece.
local config = { ids = {2238, 2239}, drop_effect = true } function examine(cid, position, corpse_id, name) if not isPlayer(cid) then return true end local corpse = getTileItemById(position, corpse_id).uid if corpse <= 1 or not isContainer(corpse) then return true end for slot = 0, getContainerSize(corpse) - 1 do local item = getContainerItem(corpse, slot) if item.uid <= 1 then return true end if isInArray(config.ids, item.itemid) then if config.drop_effect then doSendMagicEffect(position, 55, cid) end end end end function onKill(cid, target) if not isMonster(target) then return true end local monster_name = getCreatureName(target) local corpse_id = getMonsterInfo(monster_name).lookCorpse addEvent(examine, 5, cid, getThingPos(target), corpse_id, monster_name) return true endEditado Novembro 3 por koete