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

TFS 1.X+ how to get a list of all items a player has?

Tubeshop

Member
Joined
Nov 23, 2023
Messages
173
Reaction score
19
how to get a list of all items a player has? I want to have the items he wears like armor and shield and all the items in his backpack. Is it possible to download them somehow? in the next step I would like to move all these items to the player's depot? there is a possibility?

TFS 1.x
 
Solution
Well for your final result, you don't need to find all the items in the players backpack.. Just the backpack itself.
So a quick loop through all the inventory slots, copy the items, send to depot, then remove the items from the player.

In the video example, I've attached the code to my amulet of loss.

View attachment bandicam 2024-02-13 10-13-20-125.mp4

Lua:
local usePlayerTown = true -- if set to false, then will use 'no town' depot (aka: linked depots.. instead of 'thais depot')
local townId = usePlayerTown and player:getTown():getId() or 0
local depot = player:getDepotChest(townId, true)

for slot = 1, 10 do
    local thing = player:getSlotItem(slot)
    if thing then
        local copiedItem = thing:clone()
        depot:addItemEx(copiedItem, INDEX_WHEREEVER...
Well for your final result, you don't need to find all the items in the players backpack.. Just the backpack itself.
So a quick loop through all the inventory slots, copy the items, send to depot, then remove the items from the player.

In the video example, I've attached the code to my amulet of loss.

View attachment bandicam 2024-02-13 10-13-20-125.mp4

Lua:
local usePlayerTown = true -- if set to false, then will use 'no town' depot (aka: linked depots.. instead of 'thais depot')
local townId = usePlayerTown and player:getTown():getId() or 0
local depot = player:getDepotChest(townId, true)

for slot = 1, 10 do
    local thing = player:getSlotItem(slot)
    if thing then
        local copiedItem = thing:clone()
        depot:addItemEx(copiedItem, INDEX_WHEREEVER, FLAG_NOLIMIT)
        thing:remove()
    end
end
 
Solution
Well for your final result, you don't need to find all the items in the players backpack.. Just the backpack itself.
So a quick loop through all the inventory slots, copy the items, send to depot, then remove the items from the player.

In the video example, I've attached the code to my amulet of loss.

View attachment 82077

Lua:
local usePlayerTown = true -- if set to false, then will use 'no town' depot (aka: linked depots.. instead of 'thais depot')
local townId = usePlayerTown and player:getTown():getId() or 0
local depot = player:getDepotChest(townId, true)

for slot = 1, 10 do
    local thing = player:getSlotItem(slot)
    if thing then
        local copiedItem = thing:clone()
        depot:addItemEx(copiedItem, INDEX_WHEREEVER, FLAG_NOLIMIT)
        thing:remove()
    end
end
works! Thank you!
 
Back
Top