Talk:AddItem

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

HAs anyone figured out how to use this command properly in game yet? I've tried it and it doesn't work, not for one object. Stormscape 03:06, 24 March 2006 (EST)

It works[edit source]

All you have to do is open TES, find the desired item, expand the collum next to the Editor ID, and you'll see Form ID. This is the value which you are suppose to use ingame.

eg. "player.additem 0001EFD4 10" This will add 10 Silver Arrows to your inventory.


Use Editor ID, Not Form ID when doing script[edit source]

My script wasn't saving....then I figured out that the only time you use the Form ID is when you are using this in the console. I guess you use the reference ID in the script because the script is a part of the data file, so the game already has access to the form id when it checks the reference...

Note[edit source]

This won't work, however, with items that you create yourself. Due to the potential conflict of Form IDs between user-created plugins, Form IDs for user-created items appear to be dynamically generated at runtime in both the CS and game.

To get an item that you have created, add it to a merchant, somewhere in the gameworld, or create a debugging quest script that you can activate from the console.

From what I've seen, the last six digits of the Form ID in the Construction Set are the same. Only the first two digits are dynamically generated. For example, a set of custom gauntlets I created had a Form ID of 010016b6 in the editor, but the command needed to add them to my inventory was "Player.AddItem 080016b6 1". You can probably figure out the first two digits through trial and error. -- Diablerie 23:43, 15 April 2006 (EDT)
See the excellent explanation here for how the game determines the formID of items in plugins. --Kkuhlmann 14:56, 17 April 2006 (EDT)

Entim 18:41, 15 February 2007 (EST): The article says this function doesn't trigger OnAdd blocks. However OnAdd was triggered in all of my tests.

Crashing[edit source]

I've tried player.AddItem LilarcorFire, 1, AddItem LilarcorFire, 1, and AddItem LilarcorFire 1 in my script, all of them crash the game when it tries to run this. Any ideas? --MaXiMiUS 15:19, 11 April 2006 (EDT)

I fixed it with a global script. It can't have 2 copies of the script trying to run simultaneously, it seems. It has to delete the old one first, then create a new weapon with the global script. --MaXiMiUS 15:43, 13 April 2006 (EDT)

Leveled Lists?[edit source]

Apparently, PlaceAtMe does not work with leveled lists. Does AddItem work with them? --Mrflippy 12:01, 4 May 2006 (EDT)

It does work, nearly a year late but there it is--mmmpld 08:23, 27 April 2007 (EDT)

Adding Items to the Dead ?[edit source]

I've tried adding a item using this function once the actor was dead - Oblivion apparently crashes for that reason. If what I say is really true, then how do I add a item to a dead actor ? --shademe 08:41, 11 September 2008 (EDT)

Oblivion should not crash when you do that. I've personally added items to corpses via script before, so I can vouch for this working.
Dragoon Wraith TALK 11:24, 11 September 2008 (EDT)
oh, then ... it's prolly the getself on the token I added ! Thanks --shademe 09:26, 12 September 2008 (EDT)
Yes. You cannot use GetSelf when an item is in a container. You can use GetSelf on an item that has not been picked up; just make sure that you check GetContainer == 0 before using it to be certain, because it will cause a CTD. GetContainer will return whoever is holding the token, which is usually the information that a token wants.
Dragoon Wraith TALK 15:37, 12 September 2008 (EDT)
It works fine now ! Using the getContainer - anyways, does the getContainer and the getSelf return the same formID when called appropriately ? -- shademe 05:11, 13 September 2008 (EDT)
No. GetSelf returns the reference to the item itself in the gameworld. GetContainer returns the reference to the container in the gameworld that is holding the item.
Dragoon Wraith TALK 09:30, 13 September 2008 (EDT)
but getContainer seems to return the same reference as getSelf when called on a actor ( or atleast a NPC ) ... -- shademe 00:53, 15 September 2008 (EDT)
I'm surprised it even lets you call GetContainer on an NPC. GetContainer is only really defined for items that can go in inventories. When they're in an inventory, it returns the ref to that inventory, otherwise it returns 0.
I would recommend against using GetContainer on non-items; use GetSelf instead.
Dragoon Wraith TALK 10:21, 15 September 2008 (EDT)
But I'm usings it on a token I added - I am basically adding the token to a dead actor, and using getSelf in the token's script halts the script or ends up in a CTD. In my case how do I get a reference ( inside the token's code ) to the actor on which the token is used upon ? -- shademe 08:03, 17 September 2008 (EDT)
Then you would use GetContainer in the token's script - this means you are running GetContainer on the token, not on the NPC. It returns the NPC, but the function is being run on the token. Sorry for the confusion.
Dragoon Wraith TALK 11:16, 17 September 2008 (EDT)
No, I'm sorry for the confusion ! Well, thanks for clearing that ! - shademe 08:44, 18 September 2008 (EDT)

Console Usage[edit source]

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.