Description
Wiki Description
"Sells" X amount of the specified item from this reference's inventory.
Documentation Comment
jduvall
Sell item removes items from the calling container, and adds a payment to that container
it returns the number of items sold
optionally you can set:
whether the add/remove messages show up (silent) - used when the player is the container
what the payment item should be if not caps001 (paymentItem)
what container to put the payment in if not the calling container (paymentcontainer)
typical use: game.GetPlayer().SellItem(itemToSell, 5)
Caveats
CK Wiki - Notes
- 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 ObjectReference.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.
Parameters
FormItem
CK Wiki Description
what item we want to sell.
intValue
CK Wiki Description
How much each Item is worth (in other words, payment will be:Items sold * Value)
intamountToSell=-1
CK Wiki Description
How many references to remove. If < 0 means sell ALL of the specified Item in the container
boolsilent=false
CK Wiki Description
If true, no message will be printed to the screen when removing Item and adding paymentItem (only meaningful when calling on the Player)
FormpaymentItem=NONE
CK Wiki Description
what Item to give as payment. If None, means caps001.
ObjectReferencePaymentContainer=NONE
CK Wiki Description
what container to place payment in. If None, means the calling container.
Examples
; Sell up to 10 potatoes from the player's inventory for 2 caps each
Game.GetPlayer().SellItem(Potato, 2, 10)Auto-Generated Example
Form myForm__Item
int myInt__Value
int myInt__amountToSell
bool myBool__silent
Form myForm__paymentItem
ObjectReference myObjectReference__PaymentContainer
int returnedValue = myObjectReference__toCallFunctionOn.SellItem(myForm__Item, myInt__Value, myInt__amountToSell, myBool__silent, myForm__paymentItem, myObjectReference__PaymentContainer)Related Pages
Additional References
View this function’s page on the Fallout 4 Creation Kit Wiki
