• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua bug script when stacking items

7983959

New Member
Joined
Jul 29, 2017
Messages
7
Reaction score
0
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
 
You could try something like this.

Lua:
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)
        if itens then
            local itemId = itens.itemid
            local itemCount = itens.type

            doPlayerAddItemStacking(cid, itemId, itemCount)
            doPlayerSendTextMessage(cid, 20, "Looted "..itemCount.."x "..getItemNameById(itemId)..".")
            table.insert(items, itemId)
            doRemoveItem(itens.uid)
        end
    end

    if #items > 0 then
        return true
    else
        return false
    end
end
 
doesn't work, the script still pushing 1 item for each stack that already have on my backpack

i apreciate your help man.
if you have another sugest, i'll try here

still waiting and thanks !
 
Back
Top