Skip to content

Plugin Resources: Player Empty Inventory Function

XJDHDR edited this page Feb 11, 2019 · 1 revision

What is this function?

  • This is a single script in Plugin Resources that modders may use to remove every single item from an NPC or container's inventory. Though it can be used for any NPC or container in the game, it was mainly written to remove all items from the Player Character's inventory and doesn't really have any advantages when used on other containers.

Can't I just use PlayerRef.RemoveAllItems TargetContainer, 1 to do the same thing?

  • No, the RemoveAllItems function doesn't remove Quest items from the Player's inventory. Also, Unplayable items will not be removed at all. This function will remove Quest items and can optionally be instructed to remove Unplayable items as well.

Would SomeContainerThatIsNotThePlayer.RemoveAllItems TargetContainer, 1 to do the same thing as this function?

  • Almost but not quite. The RemoveAllItems function doesn't remove Unplayable items from any container or inventory. This function optionally can do so.

Are there any requirements to use this function?

  • You need OBSE v21. The function will not work at all if OBSE is not installed or too old.

How do I use this function in my mod?

  • Add one of the following commands to your script:
  • Call zzzzXjPrRemoveAllItemsFromPlayerFunctionScript rSourceContainer rDestinationContainer sRemoveUnplayable
  • Let someVar := Call zzzzXjPrRemoveAllItemsFromPlayerFunctionScript rSourceContainer rDestinationContainer sRemoveUnplayable
  • rSourceContainer is a reference to the container that will be emptied by the function (usually playerRef).
  • rDestinationContainer is a reference to the container that will receive the items taken out of the Source. Alternatively, you can set it to a reference that is not a Container or Actor to destroy all the items removed from Source.
  • sRemoveUnplayable is an Integer that will tell the function whether to remove Unplayable items from Source. If set to 0, it won't move or destroy unplayable items. If set to any other number, it will.
  • In the second example, SomeVar will be set to 0 if the function failed (because OBSE was too old or if the Source Reference isn't an Actor or Container) and 1 if it succeeded.
Clone this wiki locally