Jump to content

Retruning an object to player from a container.


antstubell

Recommended Posts

Player needs to place a specific object in a container. If the added item is wrong I want the item returned to the player - I don't want player filling up the container because it will be unavailable when the correct item is placed. This is what I have and obviously isn't working.

EDIT: I got it almost working except now player 'gets back' the item he placed in the container but the container still has the item that was placed. Basically the cotainer should discard the added object.

EDIT EDIT: I really messed up this script/ I need that when player puts an item in a container it is checked to see if it is the correct item and if not returned to the player.

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

If (IsIngredient == True) && (akBaseItem == (MyING))
MySTAing.Enable()
SFX.Play(SndHere)
MyGlobal.SetValue(1)
debug.notification(Text)
ElseIf (akBaseItem != (MyING))
Game.GetPlayer().AddItem(akBaseItem, 1)
debug.notification(Wrong)
EndIf

 

Edited by antstubell
Link to comment
Share on other sites

Sorry I can't teach you the correct script commands, but if you get no other help you might want to study the scripts of Disenchantment Fonts. There is one in Eli's Breezehome or in Obscure College of Winterhold. If you add an item to the container it's returned immediately to the player leaving no copy behind. Maybe looking at those scripts gives you an idea.

Edited by Shabdez
Link to comment
Share on other sites

FormList Property ListOfDesiredItems Auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  If ListOfDesiredItems.HasForm(akBaseItem)
    ; Item added was a desired item -- do our stuff
  Else
    ; item added was not a desired item -- send it back
    (Self as ObjectReference).RemoveItem(akBaseItem,aiItemcount,false,akSourceContainer)
  EndIf
EndEvent

Use RemoveItem to transfer items back and forth between containers (including actor inventories). AddItem will always create a new instance rather than transfer the same instance.

You do not need to use a formlist. You can change it to a specific object and compare that against the akBaseItem parameter.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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