Skip to content

SetPlayerInventory

Makes the player’s inventory exactly this list - taking what they hold beyond it and giving what they miss.

Compared by item class with what the player’s client last reported (GetPlayerInventory): a class they hold more of than the list says is taken down to the list’s number, a class they hold less of is given up to it, a class the list does not name is taken whole. A class is any key of the item catalogue; an unknown one is logged and skipped. The money stays - the purse is GivePlayerMoney’s. Everything moves by the same road as GivePlayerItem, so the inventory audit counts it. An entry with worn = true is put on (given first when they miss it; nothing happens when they wear one of the class already). Nothing is taken off: what they wear and the list keeps stays on, and what the list leaves out goes (the game takes it off them). The report lags up to a second behind the game, so an item they picked up a moment ago may not be seen yet - call it where the player is not busy (a spawn, a death, a login).

SetPlayerInventory(pid, items)
Parameter Type
pid number the player
items table a list of {class=, amount=, worn=} (amount 1 when left out, worn to put it on), as GetPlayerInventory returns it

boolean - false when not connected

-- a saved character's bags back at the login, dressed as they left (the list as GetPlayerInventory gave it then)
SetPlayerInventory(pid, saved.items)
-- a fresh start: a shirt and trousers on, a torch in the bag
SetPlayerInventory(pid, {{class = "shirt02_m01", worn = true}, {class = "trousers01_m01", worn = true}, {class = "torch_weapon"}})

GetPlayerInventory · EmptyPlayerInventory · GivePlayerItem · the Items and inventory group of the index