Difference between revisions of "RemoveItem"

738 bytes removed ,  19:48, 31 May 2008
Consolidate message spam info. Cleanup.
imported>Quetzilla
m
imported>Wrye
(Consolidate message spam info. Cleanup.)
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 15: Line 13:
  set count to 1
  set count to 1
  player.removeitem MyItem Count
  player.removeitem 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''.


<ul>
* If ObjectID is a leveled list, the leveled item generated from the leveled list will be removed.
<li>You can use a [[Variable_types:_reference_variables|reference variable]] as ''ObjectID'' and a [[Variable_types:_shortint|short]] variable for ''count''.</li>


<li>If ObjectID is a leveled list, the leveled item generated from the leveled list will be removed.</li>
* See [[Message Spam]] for techniques to avoid unwanted "Item Removed" messages.


<li>Removing an equipped item may cause a CTD. Use [[GetEquipped]] to find out if the item is equipped, and, if so, use [[UnequipItem]] before removing it.</li>
==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
<li>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:</li>
<pre>Message " "
Message " "
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.
 
<li>OBSE 0015 provides [[RemoveItemNS]] which works exactly the same as RemoveItem but without displaying any messages.</li>
 
<li>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</li>
<pre>player.AddItem YourMiscItem 1
<pre>player.AddItem YourMiscItem 1
player.EquipItem YourMiscItem
player.EquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1</pre>
player.RemoveItem YourMiscItem 1</pre>
*If the menu has been hidden with '''con_ToggleMenus''' (either via script or console) this will not work.
However, if the menu has been hidden with '''con_ToggleMenus''' (either via script or console) this will not work.
<li>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:</li>
 
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>con_ToggleMenus
<pre>con_ToggleMenus
player.RemoveItem SomeItem001 1
player.RemoveItem SomeItem001 1
Line 52: Line 40:
player.UnEquipItem YourMiscItem
player.UnEquipItem YourMiscItem
player.RemoveItem YourMiscItem 1</pre>
player.RemoveItem YourMiscItem 1</pre>
</ul>


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


[[Category: Functions]]
[[Category: Functions]]
Anonymous user