• 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 Remove a Player Item

lhc00

New Member
Joined
Mar 23, 2010
Messages
23
Reaction score
0
I would like to know how do i remove a item from the player, but i need remove just the item with a given attribute
E.g: the player has two items with the same ID but with different ActionID, the player should lose just the item with a given action ID

Thx by the attention ^_^
 
Check every slot like this:
Also you need to scan whole backpack
Lua:
for i = 1, 10 do
local slot = getPlayerSlotItem(cid, i)
if slot.itemid == ID and slot.actionid == AID then
doRemoveItem(slot.uid)
end
 
Check every slot like this:
Also you need to scan whole backpack
Lua:
for i = 1, 10 do
local slot = getPlayerSlotItem(cid, i)
if slot.itemid == ID and slot.actionid == AID then
doRemoveItem(slot.uid)
end
how i can scan whole backpack?
thanks in advance
 
how i can scan whole backpack?
thanks in advance
Code:
function scanContainer(uid, itemId, actionId)
    local offset = 0
    for i = 0, getContainerSize(uid)-1 do
        local slot = getContainerItem(uid, i+offset)
        if isContainer(slot.uid) and getContainerSize(slot.uid) > 0 then
            scanContainer(slot.uid, itemId, actionId)
        elseif slot.itemid == itemId and slot.actionid == actionId then
            doRemoveItem(slot.uid)
            offset = offset-1
        end
    end
end
 
Last edited:
Back
Top