hello everyone
i have this script for autoloot and this work nice, but have one problem.
think with me
if i already have more stacks of the same item inside my backpack
(gold coin for exemple)
when i kill a monsters, if it drop 1 gold coin
the script create 1 gold coin for each stack that i have in my backpack
if i change "doPlayerAddItemStacking "for "doPlayerAddItem"
it works perfectly. but i really want to keep the stacking function
can anyone give me a little help ?
thanks !!
function onUse(cid, item, frompos, item2, topos)
if getItemAttribute(item.uid, "corpseowner") ~= cid then
doPlayerSendCancel(cid, "You're not the owner.")
return true
end
local items = {}
for x=0, getContainerSize(item.uid) - 1 do
local itens = getContainerItem(item.uid, 0)
table.insert(items, {i=itens.itemid, q=itens.type})
doRemoveItem(itens.uid)
end
for y=1, #items do
doPlayerAddItemStacking(cid, items[y].i, items[y].q)
doPlayerSendTextMessage(cid, 20, "Looted "..items[y].q.."x "..getItemNameById(items[y].i)..".")
end
if #items > 0 then
return true
else
return false
end
end
i have this script for autoloot and this work nice, but have one problem.
think with me
if i already have more stacks of the same item inside my backpack
(gold coin for exemple)
when i kill a monsters, if it drop 1 gold coin
the script create 1 gold coin for each stack that i have in my backpack
if i change "doPlayerAddItemStacking "for "doPlayerAddItem"
it works perfectly. but i really want to keep the stacking function
can anyone give me a little help ?
thanks !!
function onUse(cid, item, frompos, item2, topos)
if getItemAttribute(item.uid, "corpseowner") ~= cid then
doPlayerSendCancel(cid, "You're not the owner.")
return true
end
local items = {}
for x=0, getContainerSize(item.uid) - 1 do
local itens = getContainerItem(item.uid, 0)
table.insert(items, {i=itens.itemid, q=itens.type})
doRemoveItem(itens.uid)
end
for y=1, #items do
doPlayerAddItemStacking(cid, items[y].i, items[y].q)
doPlayerSendTextMessage(cid, 20, "Looted "..items[y].q.."x "..getItemNameById(items[y].i)..".")
end
if #items > 0 then
return true
else
return false
end
end