Jump to content

Can't get player's items list


War

Recommended Posts

When I try to get the list of all player's inventory items it is always empty.

 

If I call

itemContainer:AddItem("Katana");

for player then the list contains 1 item. But what about already placed items in inventory? How to get them?

 

Example code:

local function Test()
    local players = getOnlinePlayers();
    if players then
        for i=0,players:size()-1 do
            local player = players:get(i);
            print(player:getUsername());
            local itemContainer = player:getInventory();
            local inventoryItems = itemContainer:getItems();
            if inventoryItems then
                print(inventoryItems:size()); -- always 0 before I add some katanas
            end
        end
    end
end

 

Any suggestions? What am I doing wrong? Thank you!

Link to comment
Share on other sites

  • 4 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...