NoCashNoExp Posted November 14, 2020 Share Posted November 14, 2020 I want to make a script that tracks the stack count of a specific item type in the player's inventory. Is there anyway to check if the player's inventory changed or even better if a specific item was added/removed? Link to comment Share on other sites More sharing options...
SKKmods Posted November 14, 2020 Share Posted November 14, 2020 Yes. Do you know how to make quests, aliases and attach scripts to them ? Link to comment Share on other sites More sharing options...
dylbill Posted November 14, 2020 Share Posted November 14, 2020 Yes, as SKK50 said you can make a new quest, start game enabled, and put a reference alias on it that points at the player. Then use the OnItemAdded and OnItemRemoved events: Something like this Scriptname MyPlayerReferenceAliasScript extends ReferenceAlias Form Property SomeItem Auto Event OnInit() AddInventoryEventFilter(SomeItem) Int CurrentAmount = Self.GetActorRef().GetItemCount(SomeItem) Debug.Notification("Current amount is " + CurrentAmount) EndEvent Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Int CurrentAmount = Self.GetActorRef().GetItemCount(SomeItem) Debug.Notification("Current amount is " + CurrentAmount) EndEvent Event OnItemRemoved(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) Int CurrentAmount = Self.GetActorRef().GetItemCount(SomeItem) Debug.Notification("Current amount is " + CurrentAmount) EndEvent Link to comment Share on other sites More sharing options...
NoCashNoExp Posted November 14, 2020 Author Share Posted November 14, 2020 (edited) Thank you both for your replies, I will test your code momentarily. I understand how to create quests and attach scripts but I didn't quite understand aliases. I will read aliases on the wiki again. This is the way I originally did it but for some reason it didn't work: Scriptname testScript extends Quest Actor Property pPlayerRef Auto Const Mandatory Event OnInit() Debug.Notification("Script Init") RegisterForRemoteEvent(pPlayerRef, "OnItemAdded") EndEvent Event ObjectReference.OnItemAdded(ObjectReference origin, Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) Debug.Notification("Item Added") EndEvent Edit: I managed to setup a player alias and tested your code and it works perfectly. Thanks again. Edited November 14, 2020 by NoCashNoExp Link to comment Share on other sites More sharing options...
dylbill Posted November 15, 2020 Share Posted November 15, 2020 No problem, glad you got it working! Link to comment Share on other sites More sharing options...
Recommended Posts