• 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!

Quickloot TFS 0.4 REV 8996

WikiArk21

New Member
Joined
Oct 24, 2023
Messages
16
Reaction score
1
I am trying to make a quickloot for my server, and I have partially succeeded, but it pulls one item for each click on the monster's body. How can I fix this error? It is an action, etc.

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getItemAttribute(item.uid, "corpseowner") ~= getPlayerGUID(cid) then
return doPlayerSendCancel(cid, "Esse corpo foi morto por outro jogador")
end

local items = {}
for i = 1, getContainerSize(item.uid) do
local it = getContainerItem(item.uid, i - 1)
if it.uid > 0 then
table.insert(items, {it.itemid, it.type})
doRemoveItem(it.uid)
end
end

if #items > 0 then
for k = 1, #items do
local playerItem = getPlayerItemById(cid, true, items[k][1])
if playerItem.uid > 0 then
local totalType = playerItem.type + items[k][2]
if totalType > 100 then
doPlayerAddItem(cid, items[k][1], totalType - 100)
doTransformItem(playerItem.uid, items[k][1], 100)
else
doTransformItem(playerItem.uid, items[k][1], totalType)
end
else
doPlayerAddItem(cid, items[k][1], items[k][2])
end
end
return true
end

return false
end
 
Solution
You are modifying the items inside the container with doRemoveItem while iterating through it which might cause it to skip items or behave unpredictably.
Try to first loop it without removing the item and remove them later to see if that fixes the problem.
You are modifying the items inside the container with doRemoveItem while iterating through it which might cause it to skip items or behave unpredictably.
Try to first loop it without removing the item and remove them later to see if that fixes the problem.
 
Solution
You are modifying the items inside the container with doRemoveItem while iterating through it which might cause it to skip items or behave unpredictably.
Try to first loop it without removing the item and remove them later to see if that fixes the problem.
I managed to fix the problem, now it's functional and even a little better. Thank you for your help
 
Back
Top