Difference between revisions of "AddItem"
→Console Usage: Moved some text to the discussion page
imported>Scruggs (onAdd block correction) |
imported>Shademe (→Console Usage: Moved some text to the discussion page) |
||
(13 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | |||
'''Syntax:''' | '''Syntax:''' | ||
[''ActorID''|''ContainerID''.]AddItem ''ObjectID'', ''Count'' | [''ActorID''|''ContainerID''.]AddItem ''ObjectID'', ''Count'' | ||
Adds ''Count'' items of object ''ObjectID'' to the calling container's inventory. | |||
'''Examples:''' | '''Examples:''' | ||
Line 14: | Line 15: | ||
set count to 1 | set count to 1 | ||
player.additem MyItem Count | player.additem MyItem Count | ||
==Notes== | ==Notes== | ||
* You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''. | * You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''. | ||
* This function will trigger an [[onAdd]] block in a script attached to the target container, as long as the container is in a loaded cell. When used on a container in a remote cell, the [[onAdd]] block won't run until the player enters that container's cell. However, if the player enters the remote cell after saving and loading, the onAdd block won't run. | |||
** Note that this is only true for the onAdd block, the rest of the script will still run if applicable (GameMode block will run if it's GameMode, MenuMode if MenuMode, etc.). The script will run once, as if it were loaded. If you have any variables set on the script, it will run the next frame as well and will continue to run until no variables are set. | |||
* See [[Message Spam]] for techniques to avoid unwanted "Item Added" messages. | |||
==Console Usage== | |||
When using AddItem with the console, you must use the desired item's FormID, not the EditorID. | |||
Console Usage | |||
So, instead of using | So, instead of using | ||
Line 35: | Line 30: | ||
to give yourself a lockpick, you must use | to give yourself a lockpick, you must use | ||
player.additem 00000A 1 | player.additem 00000A 1 | ||
==See Also== | ==See Also== | ||
*[[AddItemNS]] - Spamless version of command (OBSE 15). | |||
*[[GetItemCount]] | |||
*[[RemoveItem]] | *[[RemoveItem]] | ||
*[[ | *[[Message Spam]] - Techniques for avoiding message spam. | ||
==Reference== | ==Reference== | ||
Line 64: | Line 42: | ||
[[Category: Functions]] | [[Category: Functions]] | ||
[[Category: | [[Category:Functions (CS)]] | ||
[[Category:Actor Functions]] | [[Category: Functions (CS 1.0)]] | ||
[[Category: Inventory Functions]] | |||
[[Category: Inventory Functions (CS 1.0)]] | |||
[[Category: Actor Functions]] | |||
[[Category: Actor Functions (CS 1.0)]] | |||
<!-- Begin Search Terms | |||
Add | |||
Item | |||
End Search Terms --> |