Skip to content

GetPlayerInventory

The player’s whole inventory as the server’s records hold it.

One entry per stack: the class GUID, how many, and the items’ condition in percent (health: 0 = broken, 100 = new; items of one class in different conditions come as one entry per condition). Every piece the player wears (GetPlayerEquipment) comes as an entry of its own with amount = 1, worn = true and its own condition - so the list handed to SetPlayerInventory later dresses them the same and restores how worn each piece was. The player’s game reports every whole percent its items wear or are mended (OnPlayerItemWear). It is what the server accepted as the player’s - plus the gives still on their way, less the takes on theirs - so a GivePlayerItem or SetPlayerInventory of the mode’s own shows here at once, a save in the middle of a restore writes the bag the mode meant, and an item a cheat tool conjured is not in it under enforce. Under observe it is what the player’s game holds. {} before the player’s items are known - a moment after the spawn. The money is not in the list: the purse is GetPlayerMoney’s, and a horse’s saddlebags are GetHorseItems’s. Each of the mode’s tagged items (GivePlayerTaggedItem) comes as an entry of its own with amount = 1 and its id, name and text - and its own weight and price when it has them (SetPlayerItemWeight, SetPlayerItemPrice) - save them with the rest and SetPlayerInventory gives the same items back.

An entry’s quality is its items’ quality as the game shows it: 1 to 4 (I to IV; a masterwork forged at the anvil is the best its class can be). Items of one class at different qualities come as one entry per quality. It is left out (nil) while the player’s game has not said it - a moment after an item arrives - and for an item the game keeps at its class’s own quality. Save it with the rest: SetPlayerInventory makes the items at it again.

GetPlayerInventory(pid)
Parameter Type
pid number the player

table - a list of {class=, amount=, health=, quality=, worn=} (quality when known; worn only on what they wear; id, name, text, weight, price, model on a tagged item)

local arrows = 0
for _, stack in ipairs(GetPlayerInventory(pid)) do
local info = GetItemInfo(stack.class)
if info and info.category == "Ammo" then arrows = arrows + stack.amount end
end

GetPlayerEquipment · GivePlayerItem · GetItemInfo · SetPlayerInventory · the Items and inventory group of the index