AddItem

From the Oblivion ConstructionSet Wiki
Revision as of 18:59, 27 March 2010 by imported>Appler
Jump to navigation Jump to search


Syntax:

[ActorID|ContainerID.]AddItem ObjectID, Count 

Adds Count items of object ObjectID to the calling container's inventory.

Examples:

AddItem MyObject, 1
Ref MyItem
Short count

set MyItem to ArenaAkaviriLongSword
set count to 1
player.additem MyItem Count

Notes

  • You can use a reference variable as ObjectID and a 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.

So, instead of using

player.additem lockpick 1

to give yourself a lockpick, you must use

player.additem 00000A 1

Kedrigh wrote: [1]

Form id is in the cs and looks like this: yyxxxxxx.

yy is used to reference the plugin, xxxxxx to reference the item inside the plugin (and does not change). So if you load the oblivion master in the cs, and create something, it will have 01xxxxxx as the form id.

The yy part of the formid changes depending on the mods you load up, in the order in which they load.

  • Note: The yy part of the formID is only relevent in user-created plugins, not offical plugins, offical plugins "use" the same yy part of the form ID as the main data file(oblivion.esm) - 00.

See Also

Reference

List of existing scripts that use AddItem