Hello,
I have script in creaturescripts who check items on corpose, and send magic effect if is true, but if in corpose have bag and item inside, this script not work, and not found items.
How edit this code?
I have script in creaturescripts who check items on corpose, and send magic effect if is true, but if in corpose have bag and item inside, this script not work, and not found items.
How edit this code?
Lua:
RARE_ITEMS = {2148,5890}
function getTopItem(p) -- from Darkhaos's arena script
p.stackpos = 0
local v = getThingFromPos(p)
repeat
p.stackpos = p.stackpos + 1
v = getThingFromPos(p)
until v.itemid == 0
p.stackpos = p.stackpos - 1
return getThingFromPos(p)
end
function scanCorpseLoot(cid, pos)
local corpse = getTopItem(pos)
if isContainer(corpse.uid) then
for n = (getContainerSize(corpse.uid) - 1), 0, -1 do
if isInArray(RARE_ITEMS, getContainerItem(corpse.uid, n).itemid) then
addEvent(warningRareLoot, 400, pos, 1)
addEvent(warningRareLoot, 4000, pos, 1)
addEvent(warningRareLoot, 8000, pos, 1)
break
end
end
end
end
function warningRareLoot(pos, rtype)
if rtype == 1 then
doSendAnimatedText(pos, "RARE LOOT", TEXTCOLOR_ORANGE)
doSendMagicEffect(pos, 56) -- azul
end
end
function onKill(cid, target, lastHit)
if isMonster(target) then
addEvent(scanCorpseLoot, 150, cid, getThingPos(target))
end
return true
end