• 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 Creating items in specific backpack TFS 1.2

Fermantor

Active Member
Joined
Dec 16, 2009
Messages
209
Solutions
4
Reaction score
33
Location
Germany
So if we take obsidian knife for example, if you skin a monster and get the product (in real tibia) the product is created, where the obsidian knife is located. So if the knife lays on the ground the leather creates on the ground. If the player has it in his backpack, it creates in his backpack.
But if the player has the knife in a backpack, inside of his main backpack the skin product will be created in this specific backpack so you can't just use the function
Lua:
player:addItem(xxxx, 1)
Is there a way, of checking the backpack/container the knife is in and then create the item at this spot?

No one?
 
Last edited by a moderator:
Code:
if (fromPosition.x == CONTAINER_POSITION) then --check if is from container
   if (not item:getParent():addItem(itemId, amount)) then --check if could be added to that container where the item is located
       player:addItem(itemId, amount) --add to player if couldn't be added to that container
   end
else
   Game.createItem(itemId, amount, fromPosition) --item is on the ground, is created there
end
 
Code:
if (fromPosition.x == CONTAINER_POSITION) then --check if is from container
   if (not item:getParent():addItem(itemId, amount)) then --check if could be added to that container where the item is located
       player:addItem(itemId, amount) --add to player if couldn't be added to that container
   end
else
   Game.createItem(itemId, amount, fromPosition) --item is on the ground, is created there
end
actually this could be a function, can you create it please joe rod? :) if you dont mind for sure
 
Code:
if (fromPosition.x == CONTAINER_POSITION) then --check if is from container
   if (not item:getParent():addItem(itemId, amount)) then --check if could be added to that container where the item is located
       player:addItem(itemId, amount) --add to player if couldn't be added to that container
   end
else
   Game.createItem(itemId, amount, fromPosition) --item is on the ground, is created there
end

Oh my god, this works perfectly, thanks a lot! This one is solved!
 
Back
Top