function onKill(cid, target, lastHit)
if not(isPlayer(target)) then
addEvent(addLoot, 150, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end
function addLoot(cid, target, pos)
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
table.insert(items, getThingFromPos(pos))
end
if (#items == 0) then
return true
end
local corpse = -1
for _, item in ipairs(items) do
if isContainer(item.uid) then
corpse = item.uid
end
end
if (corpse ~= -1) and isContainer(corpse) then
if math.random(100000) <= 3000 then
doAddContainerItem(corpse, 2160)
end
end
end
local function addLoot(cid, target, pos)
local items = {}
for i = getTileInfo(pos).items, 1, -1 do
pos.stackpos = i
table.insert(items, getThingFromPos(pos))
end
if (#items == 0) then
return false
end
local corpse = -1
for _, item in ipairs(items) do
if isContainer(item.uid) then
corpse = item.uid
end
end
if (corpse ~= -1) and isContainer(corpse) then
if math.random(100000) <= 3000 then
doAddContainerItem(corpse, 2160)
end
end
return true
end
function onKill(cid, target, lastHit)
if not(isPlayer(target)) then
addEvent(addLoot, 150, cid, getCreatureName(target), getCreaturePosition(target))
end
return true
end