SellItem - ObjectReference

From the Fallout4 CreationKit Wiki
Revision as of 11:37, 19 November 2015 by imported>Plplecuyer
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Member of: ObjectReference Script

"Sells" X of the specified item from this reference's inventory..

Syntax

int Function SellItem(Form Item, int Value, int amountToSell = -1, bool silent = false, form paymentItem = none, \
  objectReference PaymentContainer = None)

Parameters

  • Item: what item we want to sell.
  • Value: How much each Item is worth (in other words, payment will be: Items sold * Value)
  • amountToSell: How many references to remove. If < 0 means sell ALL of the specified Item in the container
    • Default: -1
  • Silent: If true, no message will be printed to the screen when removing Item and adding paymentItem (only meaningful when calling on the Player)
    • Default: false
  • paymentItem: what Item to give as payment. If None, means caps001.
    • Default: None.
  • PaymentContainer: what container to place payment in. If None, means the calling container.
    • Default: None.

Return Value

How many items were sold. If you specifiy amountToSell which is greater than the actual amount of items, the return value can be used to determine how many actually were sold.

Examples

; Sell up to 10 potatoes from the player's inventory for 2 caps each
Game.GetPlayer().SellItem(Potato, 2, 10)

Notes

  • THIS FUNCTION DOES NOT TRIGGER THE OnSell() EVENT!
  • The function accepts a form object, however you can't make a property to a form object, you need to create a property to another type of object that extends form. Most often a MiscObject, or Weapon, etc.
  • Untested/verified: If you pass in a form list, it will remove AmountToSell of each item in the form list from the container. If there isn't AmountToSell of a particular item in the container, it will remove all of them.

See Also