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

How to check if player have item with action id?

Qbee

Open Tibia Fan
Joined
Mar 9, 2009
Messages
174
Reaction score
4
Im not asking about certain slot or something. is it possible to check if player have certain item with specified action id?
 
Something like (NOT TESTED, based on copyItem TFS function):
Lua:
function getItemsByActionIdOrItemId(uid, actionid, itemid, items)
	if(not items) then
		local items = {}
	end
	local item = getThing(uid)
	if((not actionid or item.actionid == actionid) and (not itemid or item.itemid == itemid)) then
		table.insert(items, item.uid)
	end
	if(isContainer(item.uid)) then
		for bp_slot = 0, getContainerSize(item.uid) - 1 do
			items = getItemsByActionIdOrItemId(getContainerItem(item.uid, bp_slot), actionid, itemid, items)
		end
	end
    return items
end

function getPlayerItemsByActionIdOrItemId(cid, actionid, itemid)
	local items = {}
	if(not isPlayer(cid)) then
		return items
	end
	for slot_id = CONST_SLOT_FIRST, CONST_SLOT_LAST do
		local slot_item = getPlayerSlotItem(cid, slot_id)
		if(slot_item.uid > 0) then
			items = getItemsByActionIdOrItemId(slot_item.uid, actionid, itemid, items)
		end
	end
	return items
end
Set itemid parameter nil to ignore item id
 
Back
Top Bottom