Difference between revisions of "AddItem"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Kkuhlmann
 
imported>Odessa
m (see also link to nvse versions)
 
(11 intermediate revisions by 7 users not shown)
Line 1: Line 1:
=='''Description'''==
{{Function
 
|CSWikiPage = AddItem
'''AddItem''' Adds Count items of object ObjectID to the calling container's inventory.  It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).
|origin = GECK1
 
|summary = Adds Count items of object ObjectID to the calling container's inventory.  It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).
=='''Syntax'''==
|name = AddItem
 
|referenceType = <nowiki>ActorID|ContainerID</nowiki>
[''ActorID|ContainerID''.]AddItem ''ObjectID, Count, MessageHiddenFlag''
|arguments = {{FunctionArgument
 
    |Name = ObjectID
=='''Examples'''==
    |Type = ref
 
  }}{{FunctionArgument
  buddyref.additem Stimpack 11
    |Name = Count
Buddy now has 11 stimpacks
    |Type = int
  }}{{FunctionArgument
    |Name = HideMessageFlag
    |Type = int
    |Optional = y
  }}
  |example = buddyref.additem Stimpack 11
Adds 11 stimpacks to Buddy's inventory
  player.additem SuperStimpak 10
  player.additem SuperStimpak 10
The player now has 10 super stimpacks and message displays like normal
Adds 10 super stimpacks to the player's inventory and the message displays like normal
  player.additem SuperStimpak 10 1
  player.additem SuperStimpak 10 1
The player now has 10 super stimpacks and no message would be displayed when these items are added
Adds 10 super stimpacks to the player's inventory and no message is displayed
}}


=='''Notes'''==
==Notes==
*You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.  
*You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.


=='''See Also'''==
==Bugs==
[[RemoveItem]]<br>
<ul><li>Calling [[AddItem]] in an Effect Script or in an [[OnEquip]] block in an Object Script will cause the target actor's weapon to toggle between being visible and usable and being invisible and unusable. The cause of this bug is unknown, but as a workaround, use something like this in the script of the item that is being added:
[[AddItemHealthPercent]]
<pre>ref rContainer
Begin OnAdd
set rContainer to GetContainer
rContainer.AddItem Pencil01 1 1
rContainer.RemoveItem Pencil01 1 1
End</pre></li></ul>
*Executing [[AddItem]] function on [[NPC]]s will cause them to review their inventory and equip the best armor and weapon they have. If [[NPC]] already has an armor with [[Object Effect]]s equipped adding an item will make them reequip it, not really unequipping it first. As a result [[Object Effect]]s of the armor will stack after each use of the [[AddItem]] function. Unequipping the armor will revert everything back to normal removing all stacked [[Object Effect]]s.


=='''Reference'''==
==See Also==
None provided.
*[[AddItemHealthPercent]]
<!-- [[AddItem_Reference|List of functions that use AddItem]] (wiki) -->
*[[AddItemOwnership]]
*[[AddItemHealthPercentOwner]]
*[[GetItemCount]]
*[[RemoveItem]]


[[Category:Functions]]
[[Category:Functions]]
[[Category:Functions (GECK 1.1)]]

Latest revision as of 17:33, 16 July 2014

< [[::Category:Functions|Category:Functions]]

Link to TES4 Construction Set Wiki: AddItem.

A function included in the GECK version 1.1.0.36.

Description

Adds Count items of object ObjectID to the calling container's inventory. It has two required parameters (the object to add and the quantity) and one optional parameter (whether to display a message on screen).

Syntax

[help]
ActorID|ContainerID.AddItem ObjectID:ref Count:int HideMessageFlag:int

Example

buddyref.additem Stimpack 11

Adds 11 stimpacks to Buddy's inventory

player.additem SuperStimpak 10

Adds 10 super stimpacks to the player's inventory and the message displays like normal

player.additem SuperStimpak 10 1

Adds 10 super stimpacks to the player's inventory and no message is displayed

Notes

  • You can use a FormList as the item parameter - in this case, the function adds the count for each item in the list.

Bugs

  • Calling AddItem in an Effect Script or in an OnEquip block in an Object Script will cause the target actor's weapon to toggle between being visible and usable and being invisible and unusable. The cause of this bug is unknown, but as a workaround, use something like this in the script of the item that is being added:
    ref rContainer
    Begin OnAdd
    	set rContainer to GetContainer
    	rContainer.AddItem Pencil01 1 1
    	rContainer.RemoveItem Pencil01 1 1
    End
  • Executing AddItem function on NPCs will cause them to review their inventory and equip the best armor and weapon they have. If NPC already has an armor with Object Effects equipped adding an item will make them reequip it, not really unequipping it first. As a result Object Effects of the armor will stack after each use of the AddItem function. Unequipping the armor will revert everything back to normal removing all stacked Object Effects.

See Also