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 server’s records hold (GetPlayerInventory, the gives and takes still on their way
counted): 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: what is given is the server’s record from
this moment and counts as the character’s the moment it is given, though the player’s game makes it a moment later (an
item that was saved but is no longer in the game is dropped from the records after half an hour, never reported made), and
what is taken is an exact order the game carries out. An entry’s health is the condition its items should have (0..100,
100 when left out): a missing item is made at it, and an item they already hold is set to it. Its quality (1..4, left out =
the class’s own) is the same: a missing item is made at that quality, one they hold is set to 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). Called twice before the
first call’s orders are done, it orders nothing twice, so it is safe at any moment - a spawn, a death, a login - and the
restore of a saved character may follow it with GetPlayerInventory and save at once. The log says
SetPlayerInventory: N given, M taken. An entry with an id is one of the mode’s tagged items
(GivePlayerTaggedItem): one they hold with that id is kept (its name and text updated), a missing one is made with
its tag, and a tagged item they hold whose id the list does not name is taken - that exact item.
Syntax
Section titled “Syntax”SetPlayerInventory(pid, items)| Parameter | Type | |
|---|---|---|
pid |
number | the player |
items |
table | a list of {class=, amount=, health=, quality=, worn=} (amount 1 and health 100 when left out, quality the class’s own, worn to put it on; id, name, text for a tagged item), as GetPlayerInventory returns it |
Returns
Section titled “Returns”boolean - false when not connected
Example
Section titled “Example”-- 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 hose on, a torch in the bagSetPlayerInventory(pid, {{class = "TunicShort06_m01_D", worn = true}, {class = "HoseJoined01_m01_C", worn = true}, {class = "torch_weapon"}})See also
Section titled “See also”GetPlayerInventory · EmptyPlayerInventory · GivePlayerItem · the Items and inventory group of the index
