cooldamien Posted February 17, 2017 Share Posted February 17, 2017 Like to count how many Items are in a container so I script a display shelf. Please take look at my script. Thank you for your guys help Scriptname Dam_BarFrigerator01 extends ObjectReference ;============================ ;PROPERTIES ;============================ Potion Property BeerGwinnettAle Auto Potion Property NukaCola Auto Potion[] Property FoodType Auto ObjectReference Property Dam_ColaMarker Auto ObjectReference Property Dam_GwinnettAleXMarker Auto ;============================ ;EVENTS ;============================ auto STATE AllowActivate Event OnActivate(ObjectReference akActionRef) ; Block activation of the stand when the players activates it, delete the bobbleheads, swap their Quest Object... ; ...status if the player currently has them, and then display the bobbleheads when the player leaves the container screen. GoToState("Busy") BlockActivation(TRUE) AddInventoryEventFilter(NONE) debug.Trace(self + "OnActivate()") if akActionRef == Game.GetPlayer() Utility.Wait(0.1) endif GoToState("AllowActivate") BlockActivation(FALSE) EndEvent EndSTATE STATE Busy ;Do Nothing EndSTATE Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) debug.Trace(self + "OnItemAdded() " + aiItemCount + " " + akBaseItem) If (akBaseItem As Potion) ;Place in Container Debug.Notification("Added food item") Else Self.RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) Debug.MessageBox("Invalid Item") EndIf If akBaseItem == NukaCola ; Enable Display Dam_ColaMarker.enable() EndIf If akBaseItem == BeerGwinnettAle ; Enable Display Dam_GwinnettAleXMarker.Enable() EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == NukaCola ; Disable Display Dam_ColaMarker.disable() EndIf If akBaseItem == BeerGwinnettAle ; Disable Display Dam_GwinnettAleXMarker.disable() EndIf EndEvent Link to comment Share on other sites More sharing options...
shavkacagarikia Posted February 17, 2017 Share Posted February 17, 2017 You dont need that script to just count items in container. There is a function GetItemCount(), if its parameter is none, it will return a total amount of items in container. Like: YourContainer.GetItemCount() will do what you want Link to comment Share on other sites More sharing options...
cooldamien Posted February 17, 2017 Author Share Posted February 17, 2017 I wish use the GetItemCount() in the above script. That way when NukaCola is put in the container the near by self show the NukaCola or takes it a way when taken from the container. The above script sorta does what I am looking for but I have been unable to the GetItemCount() working. Thank you for your reply and your help. Damien Link to comment Share on other sites More sharing options...
cooldamien Posted February 17, 2017 Author Share Posted February 17, 2017 I figured it out the GetItemCount() was exactly what I was looking for. You can see how I used the function in my code. Wish there was a better way show and hide items than a bunch of Xmakers. Anyway thank you for your help. Damien Scriptname Dam_BarFrigerator01 extends ObjectReference ;============================ ;PROPERTIES ;============================ Potion Property BeerGwinnettAle Auto Potion Property NukaCola Auto Potion[] Property FoodType Auto ObjectReference Property Dam_ColaMarker Auto ObjectReference Property Dam_GwinnettAleXMarker Auto int NuckCont = 0 int GwinnetCont = 0 ;============================ ;EVENTS ;============================ auto STATE AllowActivate Event OnActivate(ObjectReference akActionRef) GoToState("Busy") BlockActivation(TRUE) AddInventoryEventFilter(NONE) debug.Trace(self + "OnActivate()") if akActionRef == Game.GetPlayer() Utility.Wait(0.1) endif GoToState("AllowActivate") BlockActivation(FALSE) EndEvent EndSTATE STATE Busy ;Do Nothing EndSTATE Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == NukaCola ; Check Item NuckCont = GetItemCount(akBaseItem) ; Get a count of NukaCola EndIf If akBaseItem == BeerGwinnettAle ; Check item GwinnetCont = GetItemCount(akBaseItem) ; Get a count of GwinnettAle EndIf debug.Trace(self + "OnItemAdded() " + aiItemCount + " " + akBaseItem) If (akBaseItem As Potion) ;Place in Container Debug.Notification("Added food item") Else Self.RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) Debug.MessageBox("Invalid Item") EndIf If NuckCont > 0 ; Enable Display Dam_ColaMarker.enable() EndIf If GwinnetCont > 0 ; Enable Display Dam_GwinnettAleXMarker.Enable() EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem == NukaCola ; Check Item NuckCont = GetItemCount(akBaseItem) ; Get a count of NukaCola EndIf If akBaseItem == BeerGwinnettAle ; Check item GwinnetCont = GetItemCount(akBaseItem) ; Get a count of GwinnettAle EndIf If NuckCont < 1 ; Disable Display Dam_ColaMarker.disable() EndIf If GwinnetCont < 1 ; Disable Display Dam_GwinnettAleXMarker.disable() EndIf EndEvent Link to comment Share on other sites More sharing options...
Recommended Posts