Complete Example Scripts: Difference between revisions

Jump to navigation Jump to search
imported>Fg109
imported>Scrivener07
Line 799: Line 799:




=== Script a container that only accepts certain items by [[User:Scrivener07|Scrivener07]] 24 April 2012 ===
=== Script a container that only accepts certain types of items: by [[User:Scrivener07|Scrivener07]] 24 April 2012 ===
'''How to use this script''': Change the ITEM property to whatever you want and the container will only accepts those items. If you want a container that only accepts an item that isnt a MiscObject just change the property type to the correct type.  
'''How to use this script''': Change the ITEM properties to whatever you want and the container will only accepts those items. If you want a container that only accepts an item that isnt a MiscObject just change the property type to the correct type. If you require your container to accept more than just three item types add another property for the item followed by another If (akBaseItem !=  ITEM4). Dont forget your Endif!
<Source lang="Papyrus">
<Source lang="Papyrus">
Scriptname ExampleContainerScript extends ObjectReference   
Scriptname ExampleContainerScript extends ObjectReference   


Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
akSourceContainer = Game.GetPlayer()


If akBaseItem !=  ITEM
If (akBaseItem !=  ITEM1)
Self.RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
If (akBaseItem !=  ITEM2)
Debug.Notification("Invalid Item")
If (akBaseItem !=  ITEM2)
Self.RemoveItem(akBaseItem, aiItemCount, True)
Game.GetPlayer().Additem(akBaseItem, aiItemCount, True)
Debug.Notification("Invaild Item")
Endif
Endif
EndIf
EndIf


EndEvent
EndEvent
MiscObject Property ITEM Auto   
MiscObject Property ITEM1 Auto   
MiscObject Property ITEM2  Auto
MiscObject Property ITEM3  Auto
</Source>
</Source>
Anonymous user

Navigation menu