• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[TFS 1.4] List Player Items

Itutorial

Legendary OT User
Joined
Dec 23, 2014
Messages
2,461
Solutions
68
Reaction score
1,123
This will show a list of a players equipment (slots) and all items they have on them. Including in backpacks. It counts all items and tells you the amount.

If the player has more than 255 different items on them those items will not be added to the list. I will eventually release something to fix that.

LUA:
local playerItems = TalkAction("/items")

local slots = {
    [1] = {slot = CONST_SLOT_HEAD, name = "[Head]: "},
    [2] = {slot = CONST_SLOT_NECKLACE, name = "[Necklace]: "},
    [3] = {slot = CONST_SLOT_BACKPACK, name = "[Backpack]: "},
    [4] = {slot = CONST_SLOT_ARMOR, name = "[Armor]: "},
    [5] = {slot = CONST_SLOT_RIGHT, name = "[Right Hand]: "},
    [6] = {slot = CONST_SLOT_LEFT, name = "[Left Hand]: "},
    [7] = {slot = CONST_SLOT_LEGS, name = "[Legs]: "},
    [8] = {slot = CONST_SLOT_FEET, name = "[Feet]: "},
    [9] = {slot = CONST_SLOT_RING, name = "[Ring]: "},
    [10] = {slot = CONST_SLOT_AMMO, name = "[Ammo]: "}
}

function playerItems.onSay(player, words, param)
    local target = nil
    
    if not param or param == "" then
        target = player
    else
        target = Player(param)
    end
    
    if not target then
        player:sendCancelMessage("Player is not online or doesn't exist.")
        return false
    end
    
    
    local container = player:getSlotItem(CONST_SLOT_BACKPACK)
    

    if container then
        local containerItems = container:getItems(true)
        
        local items = {}
            
        for i = 1, #containerItems do
            if not items[containerItems[i]:getName()] then
                items[containerItems[i]:getName()] = 0
            end
            
            if containerItems[i]:getCount() and containerItems[i]:getCount() > 1 then
                items[containerItems[i]:getName()] = items[containerItems[i]:getName()] + containerItems[i]:getCount()
            else
                items[containerItems[i]:getName()] = items[containerItems[i]:getName()] + 1
            end
        end
            
        local text2 = ""
        local nLine = 0

        for i, v in pairs(items) do
            text2 = text2.."["..i.."]: "..v.."\n"
            nLine = nLine + 1
            
            if nLine == 244 then
                nLine = 0
                player:showTextDialog(1111, text2)
                text2 = ""
            end
        end

        player:showTextDialog(1111, text2)
    end
    
    local text = ""
    
    for i = 1, #slots do
        local item = target:getSlotItem(slots[i].slot)
        if item then
            text = text..""..slots[i].name..""..item:getName().."\n"
        else
            text = text..""..slots[i].name.."nothing\n"
        end
    end
    
    player:showTextDialog(1111, text)

    return false
end

playerItems:separator(" ")
playerItems:register()
 
Hi, I feel like this can be useful for something, but I can't think about it. What was the reason you used it for? Were u just curious about the players items, catching a cheater?
 
This will show a list of a players equipment (slots) and all items they have on them. Including in backpacks. It counts all items and tells you the amount.

If the player has more than 255 different items on them those items will not be added to the list. I will eventually release something to fix that.

LUA:
local playerItems = TalkAction("/items")

local slots = {
    [1] = {slot = CONST_SLOT_HEAD, name = "[Head]: "},
    [2] = {slot = CONST_SLOT_NECKLACE, name = "[Necklace]: "},
    [3] = {slot = CONST_SLOT_BACKPACK, name = "[Backpack]: "},
    [4] = {slot = CONST_SLOT_ARMOR, name = "[Armor]: "},
    [5] = {slot = CONST_SLOT_RIGHT, name = "[Right Hand]: "},
    [6] = {slot = CONST_SLOT_LEFT, name = "[Left Hand]: "},
    [7] = {slot = CONST_SLOT_LEGS, name = "[Legs]: "},
    [8] = {slot = CONST_SLOT_FEET, name = "[Feet]: "},
    [9] = {slot = CONST_SLOT_RING, name = "[Ring]: "},
    [10] = {slot = CONST_SLOT_AMMO, name = "[Ammo]: "}
}

function playerItems.onSay(player, words, param)
    local target = nil
   
    if not param or param == "" then
        target = player
    else
        target = Player(param)
    end
   
    if not target then
        player:sendCancelMessage("Player is not online or doesn't exist.")
        return false
    end
   
   
    local container = player:getSlotItem(CONST_SLOT_BACKPACK)
   

    if container then
        local containerItems = container:getItems(true)
       
        local items = {}
           
        for i = 1, #containerItems do
            if not items[containerItems[i]:getName()] then
                items[containerItems[i]:getName()] = 0
            end
           
            if containerItems[i]:getCount() and containerItems[i]:getCount() > 1 then
                items[containerItems[i]:getName()] = items[containerItems[i]:getName()] + containerItems[i]:getCount()
            else
                items[containerItems[i]:getName()] = items[containerItems[i]:getName()] + 1
            end
        end
           
        local text2 = ""
        local nLine = 0

        for i, v in pairs(items) do
            text2 = text2.."["..i.."]: "..v.."\n"
            nLine = nLine + 1
           
            if nLine == 244 then
                nLine = 0
                player:showTextDialog(1111, text2)
                text2 = ""
            end
        end

        player:showTextDialog(1111, text2)
    end
   
    local text = ""
   
    for i = 1, #slots do
        local item = target:getSlotItem(slots[i].slot)
        if item then
            text = text..""..slots[i].name..""..item:getName().."\n"
        else
            text = text..""..slots[i].name.."nothing\n"
        end
    end
   
    player:showTextDialog(1111, text)

    return false
end

playerItems:separator(" ")
playerItems:register()
is it possible to make it show only your eq and everyone can check everyones eq using command np !item (playername)?
 
Maybe this can work for canary users...

LUA:
local equipment = TalkAction("!spy")

local slots = {
    [1]  = {slot = CONST_SLOT_HEAD,      name = "Head Slot"},
    [2]  = {slot = CONST_SLOT_NECKLACE,  name = "Amulet Slot"},
    [3]  = {slot = CONST_SLOT_BACKPACK,  name = "Backpack Slot"},
    [4]  = {slot = CONST_SLOT_ARMOR,     name = "Armor Slot"},
    [5]  = {slot = CONST_SLOT_RIGHT,     name = "Right Hand"},
    [6]  = {slot = CONST_SLOT_LEFT,      name = "Left Hand"},
    [7]  = {slot = CONST_SLOT_LEGS,      name = "Legs Slot"},
    [8]  = {slot = CONST_SLOT_FEET,      name = "Feet Slot"},
    [9]  = {slot = CONST_SLOT_RING,      name = "Ring Slot"},
    [10] = {slot = CONST_SLOT_AMMO,      name = "Ammo Slot"}
}

local function getContainerItems(container, indent)
    local text = ""
    local prefix = string.rep("-", indent) .. "> "

    for i = 0, container:getSize() - 1 do
        local item = container:getItem(i)
        if item then
            local count = item:getCount() > 1 and " (" .. item:getCount() .. "x)" or ""
            text = text .. "\n" .. prefix .. item:getName() .. count

            if item:isContainer() then
                text = text .. getContainerItems(item, indent + 1)
            end
        end
    end
    return text
end

function equipment.onSay(player, words, param)
    if param == "" then
        player:sendCancelMessage("Command requires a player name.")
        return false
    end

    local target = Player(param)
    if not target then
        player:sendCancelMessage("This player is not online.")
        return false
    end

    local text = target:getName() .. "'s Equipment:\n"

    for i = 1, #slots do
        local data = slots[i]
        local item = target:getSlotItem(data.slot)

        if item then
            text = text .. data.name .. ": " .. item:getName()

            -- SOLO containers accesibles por Canary
            if item:isContainer() then
                text = text .. getContainerItems(item, 1)
            end
        else
            text = text .. data.name .. ": Empty"
        end

        text = text .. "\n"
    end

    player:showTextDialog(6579, text)
    return false
end

equipment:separator(" ")
equipment:groupType("god")
equipment:register()
 
Back
Top