Jump to content

Script for container help please


MaddDreamer

Recommended Posts

Technically, the OnItemAdded event will always run no matter what item is added and irregardless of whether it has or has not been in the container before.

 

Some example usages:

 

 

Do something when an item is added to the container -- this version always runs when an item is added. Depending upon number of items added, processing could slow down as each item must be compared.

Scriptname SomeContainerScript Extends ObjectReference
 
MiscObject Property MyMiscObject Auto
;change property type as necessary - this is for the item you want to work with
 
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  If akBaseItem == MyMiscObject
    ; do stuff
  Else
    Return
  EndIf
EndEvent
Do something when an item and only that item is added to a container -- this version is processing friendly in that the OnItemAdded event will only be triggered when the specified object is added, all other items will be ignored.
Scriptname SomeContainerScript Extends ObjectReference
 
MiscObject Property MyMiscObject Auto
;change property type as necessary - this is for the item you want to work with
 
Event OnInit()
  AddInventoryEventFilter(MyMiscObject)
EndEvent
 
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  ; do stuff
EndEvent

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...