Difference between revisions of "RemoveItem"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
imported>Dev akm
(→‎Notes: Troubleshooting link)
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
Removes ''count'' number of the specified item from the calling object's inventory.
Removes ''count'' number of the specified item from the calling object's inventory.


'''Syntax:'''
'''Syntax:'''
  RemoveItem ''ObjectID'', ''count''
  RemoveItem ''ObjectID'', ''count''


'''Examples:'''
'''Examples:'''
Line 16: Line 14:
  player.removeitem MyItem Count
  player.removeitem MyItem Count


==Notes==
* Suffers from the same stability limitations as [[RemoveMe]]. Using RemoveItem immediately after the object has been added will often result in a crash. To prevent this, wait more than one frame before you remove the item.
* You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''.


* If ObjectID is a leveled list, the leveled item generated from the leveled list will be removed.


==Notes==
* See [[Message Spam]] for techniques to avoid unwanted "Item Removed" messages.


* You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''.  
* RemoveItem is not always reliable when removing multiple items at once. See [[Common_Bugs#Remove_Item|Troubleshooting: Common Bugs]].


*If ObjectID is a leveled list, the leveled item generated from the leveled list will be removed.
==Inventory Updating==
When you remove an item while the player's inventory menu ([[MenuMode]] 1002) is open, the item will remain visible even though it's really not there. To refresh the menu after removing the item, use
<pre>player.AddItem YourMiscItem 1
player.EquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1</pre>
However, if the menu has been hidden with '''con_ToggleMenus''' (either via script or console) this will not work.


*By default, using this function on the player will display a message informing the player that the item in question has been removed. In many situations, this is very annoying, but you can use a pair of blank [[Message]] calls to prevent it from happening, like so:
When you remove a large number of unique items from the player while their inventory menu is open, there may be some lag. You can prevent this with OBSE's [[con_ToggleMenus]] by placing it on both sides of the remove lines:
<pre>Message " "
<pre>con_ToggleMenus
Message " "
player.RemoveItem SomeItem001 1
player.RemoveItem "item ID" 1</pre>
...
This seems to shortcircuit the message display and will prevent any other messages from being queued or displayed for a couple of seconds. [[Avoiding Message Spam|Here]] are some alternative methods that don't disrupt other messages.
player.RemoveItem SomeItem100 1
con_ToggleMenus
;Refresh the menu
player.AddItem YourMiscItem 1
player.EquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1</pre>


==See Also==
==See Also==
*[[RemoveItemNS]] - Spamless version of command (OBSE 15).
*[[AddItem]]
*[[AddItem]]
*[[GetItemCount]]
*[[GetItemCount]]
*[[RemoveAllItems]]
*[[RemoveAllItems]]
*[[Preventing messages]]
*[[Message Spam]] - Preventing message spam.


[[Category: Functions]]
[[Category: Functions]]
[[Category:Functions (CS)]]
[[Category: Functions (CS 1.0)]]
[[Category: Functions (CS 1.0)]]
[[Category: Inventory Functions]]
[[Category: Inventory Functions]]
[[Category: Inventory Functions (CS 1.0)]]
[[Category: Inventory Functions (CS 1.0)]]
<!-- Begin Search Terms
Remove
Item
End Search Terms -->

Latest revision as of 11:08, 14 April 2009

Removes count number of the specified item from the calling object's inventory.

Syntax:

RemoveItem ObjectID, count

Examples:

RemoveItem Gold001 50
Ref MyItem
Short count

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

Notes[edit | edit source]

  • Suffers from the same stability limitations as RemoveMe. Using RemoveItem immediately after the object has been added will often result in a crash. To prevent this, wait more than one frame before you remove the item.
  • If ObjectID is a leveled list, the leveled item generated from the leveled list will be removed.
  • See Message Spam for techniques to avoid unwanted "Item Removed" messages.

Inventory Updating[edit | edit source]

When you remove an item while the player's inventory menu (MenuMode 1002) is open, the item will remain visible even though it's really not there. To refresh the menu after removing the item, use

player.AddItem YourMiscItem 1
player.EquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1

However, if the menu has been hidden with con_ToggleMenus (either via script or console) this will not work.

When you remove a large number of unique items from the player while their inventory menu is open, there may be some lag. You can prevent this with OBSE's con_ToggleMenus by placing it on both sides of the remove lines:

con_ToggleMenus
player.RemoveItem SomeItem001 1
...
player.RemoveItem SomeItem100 1
con_ToggleMenus
;Refresh the menu
player.AddItem YourMiscItem 1
player.EquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1

See Also[edit | edit source]