• 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 TFS 1.2 check container

Aeronx

Intermediate OT User
Joined
Dec 17, 2015
Messages
736
Solutions
9
Reaction score
121
for i = 0, getContainerSize(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid)-1 do
thing = getContainerItem(getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid, i)
local resto = isInArray(thing.itemid, 8293)
print(resto)
print(thing.itemid)
end
resto prints all false..
thing.itemid prints all the items in bp.. item 8293 is in bp, but still return false.

is this part wrong? isInArray(thing.itemid, 8293) or what am i doing wrong?

Thanks in advance.
 
Can you tell what are you trying to accomplish and whats your tfs version?
 
TFS version is on title. And im trying to check if player has an item on backpack onUse.

So "thing.itemid" prints all itemid of the items inside container. Once i have all the item in bp..

if thing.itemid == 8293 then... etc
 
you don't understand how isInArray works, you're trying to compare item.itemid with a number
isInArray takes a table and a value to check if that value is inside of the table, returns true or false
all you need to do is check item.itemid == some value
or if you want to use multiple ids to check
isInArray({xx, xx, xx}, item.itemid)
 
You should use:
Code:
// player:getItemCount(itemId[, subType = -1])
// player:getItemById(itemId, deepSearch[, subType = -1])
 
Thanks for your answers.. maybe its too late for me and im not thinking straight lol

What does exactly do deepSearch? Is it possible to see it on an example?

Jesus.. so easy with getItemCount >.< im damn retard. Thanks guys!
 
Last edited by a moderator:
deepSearch goes through all possible containers in the player's inventory, you put either true or false
if player:getItemById(8293, true) then
 
Back
Top