local configs = {
ids = {2148, 2152, 2160}, -- adicionado somente os dos dinheiros, mais pode adicionar qual id quiser.
premium = true -- só premium usar o auto loot ? [true ou false]
}
function getItemsInContainerById(container, itemid)
local items = {}
if getContainerSize(container) > 0 then
for slot=0, (getContainerSize(container)-1) do
local item = getContainerItem(container, slot)
if isContainer(item.uid) then
local itemsbag = getItemsInContainerById(item.uid, itemid)
for i=0, #itemsbag do
table.insert(items, itemsbag)
end
else
if itemid == item.itemid then
table.insert(items, item.uid)
end
end
end
end
return items
end
function autoGold(cid, pos, stack)
if stack > 255 then return true end
local position = {x = pos.x, y = pos.y, z = pos.z, stackpos = stack}
local tile = getThingFromPos(position)
if isCorpse(tile.uid) then
corpse = tile
else
autoGold(cid, pos, stack + 1)
end
if corpse ~= nil then
for _, idmoney in pairs(configs.ids) do
tab = getItemsInContainerById(corpse.uid, idmoney)
if #tab ~= 0 then
for _, uid in pairs(tab) do
item = getThing(uid)
doPlayerAddItem(cid, idmoney, item.type)
doRemoveItem(item.uid, item.type)
end
end
end
end
end
function onKill(cid, target)
if not isPremium(cid) and configs.premium then return true end
return addEvent(autoGold, 10, cid, getCreaturePosition(target), 0)
end