ScriptName NNWBeutelSkript extends ObjectReference

ObjectReference Property NNWStatischeTruhe Auto
MiscObject Property NNWBeutel Auto
Sound Property KlapperKlapper Auto
Message Property NNWTascheNachricht Auto
ObjectReference Ich
Actor Property PlayerRef Auto

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
  If(akOldContainer && !akNewContainer)
  Ich = (Self as ObjectReference)
	Ich.BlockActivation()
  ElseIf(akNewContainer == NNWStatischeTruhe)
		NNWTascheNachricht.Show()
		Utility.Wait(1)
	NNWStatischeTruhe.RemoveItem(NNWBeutel, 1, False)
	PlayerRef.AddItem(NNWBeutel, 1)
  endIf
endEvent

Event OnEquipped(Actor akActor)
	If(akActor == PlayerRef)
		Utility.Wait(1)
 		KlapperKlapper.Play(PlayerRef)
		NNWStatischeTruhe.Activate(PlayerRef)
	endif
EndEvent

Event OnActivate(ObjectReference akActionRef)
	
	If(akActionRef == PlayerRef)
	If(PlayerRef.IsSneaking())
			KlapperKlapper.Play(PlayerRef)
			NNWStatischeTruhe.Activate(PlayerRef)
	Else
	Ich.Activate(akActionRef, True)
 	EndIf
	EndIf
EndEvent