Difference between revisions of "AddItem - ObjectReference"
Jump to navigation
Jump to search
imported>Thepal |
imported>SarthesArai m (→Notes: shortening link) |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 33: | Line 33: | ||
== Notes == | == Notes == | ||
Don't call this function immediately when a game is started/loaded as it does not seem to work. You can have the game [[Wait_-_Utility|Wait]] a second before doing it which should correct this problem. | * An item added to a respawning chest using AddItem will most likely not appear. This is due to the chest resetting its contents every day or so. If the player has not talked to the merchant recently, their inventory will reset before they see the item in it. | ||
* Don't call this function immediately when a game is started/loaded as it does not seem to work. You can have the game [[Wait_-_Utility|Wait]] a second before doing it which should correct this problem. | |||
* akItemToAdd can be a LeveledItem. Removal of a LeveledItem, however won't work with [[RemoveItem - ObjectReference|RemoveItem]] and the members of the LeveledItem must be passed individually as akItemToRemove. | |||
* As of Skyrim version 1.6, it is no longer possible to use AddItem to add an Object or ObjectReference of type Container to the player's inventory. | |||
== See Also == | == See Also == |
Latest revision as of 11:22, 20 August 2016
Member of: ObjectReference Script
Adds X of the specified item to this reference's inventory, possibly silently.
Syntax[edit | edit source]
Function AddItem(Form akItemToAdd, int aiCount = 1, bool abSilent = false) native
Parameters[edit | edit source]
- akItemToAdd: The base form add to this reference's inventory. If this is a base object, it will add a newly-created item. If it is a reference, it will move/remove it from own place/container to this container. If a form list, then it will add aiCount of each item in the list.
- aiCount: How many references to add. Note that this must be one if you are passing in an object reference.
- Default: 1
- abSilent: If true, no message will be printed to the screen
- Default: false
Return Value[edit | edit source]
None.
Examples[edit | edit source]
; Add a two diamonds to the player's inventory, silently
Game.GetPlayer().AddItem(Diamond, 2, true)
; Move the special gem reference from wherever it is into the chest
Chest.AddItem(SpecialGemRef)
Notes[edit | edit source]
- An item added to a respawning chest using AddItem will most likely not appear. This is due to the chest resetting its contents every day or so. If the player has not talked to the merchant recently, their inventory will reset before they see the item in it.
- Don't call this function immediately when a game is started/loaded as it does not seem to work. You can have the game Wait a second before doing it which should correct this problem.
- akItemToAdd can be a LeveledItem. Removal of a LeveledItem, however won't work with RemoveItem and the members of the LeveledItem must be passed individually as akItemToRemove.
- As of Skyrim version 1.6, it is no longer possible to use AddItem to add an Object or ObjectReference of type Container to the player's inventory.