SellItem - ObjectReference

Revision as of 18:33, 15 April 2017 by imported>Qazaaq (Changed the item parameter note to be more clear about its mention of properties.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Member of: ObjectReference Script

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

SyntaxEdit

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

ParametersEdit

  • 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 ValueEdit

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.

ExamplesEdit

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

NotesEdit

  • The generic Item parameter accepts a form object, however you must provide a higher type of object that extends form. Most often a MiscItem, or Weapon, etc.
  • This function does not trigger OnSell() event.
  • 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 AlsoEdit