Autostorage Script - conditional MessageBox display

Post » Thu Sep 04, 2014 8:35 pm

Hi there,

This script is to store my crafting materials into a container. I attach the script to the container, when the player activates, the script is to check the player inventory for a list of items (via FormID list), then if conditions are met, display a messagebox with options that allow the player to choose what is stored.

The problem I am having is, the messagebox is being displayed even when there are no items in the player inventory. So, clearly the inventory check that I wrote at the beginning is not properly working. The other two checks that I wrote inside the function seem to be working though (i.e. if I select the button 1 (smelting items) and i do not have any items, the correct message is displayed indicating i do not have any smelting items).

My intention is to prevent the messagebox from being displayed if the player has < 1 item from the main MRW_craftinglist formlist.

Here is the script:

Scriptname MRW_CraftingStorage_Simple extends ObjectReference  {This script only stores crafting supplies}	Import Game	Import Utility	Import Debug	Message Property MRW_CraftingMainMessageBox auto	FormList Property MRW_CraftingList auto	FormList Property MRW_SmeltingList auto	FormList Property MRW_TanningList auto	Int Counter0	Int Counter1	Int Counter2Event OnActivate(ObjectReference akActionRef)	Counter0 = GetPlayer().GetItemCount(MRW_CraftingList)	String NoCraftingSupplies = "You have no crafting supplies"					If Counter0 < 1			Notification(NoCraftingSupplies)		Else				WaitMenuMode(0.4)			Return CraftingMenu()		EndifEndEventFunction CraftingMenu()													;STORE CRAFTING SUPPLIES			Actor Player = GetPlayer()			Counter0 = Player.GetItemCount(MRW_CraftingList)			Counter1 = Player.GetItemCount(MRW_SmeltingList)			Counter2 = Player.GetItemCount(MRW_TanningList)			String NoCraftingSupplies = "You have no crafting supplies"			String NoSmeltingSupplies = "You have no smelting supplies"			String NoTanningSupplies = "You have no tanning supplies"			String CraftingStored = "Your crafting supplies have been stored"			String SmeltingStored = "Your smelting supplies have been stored"			String TanningStored = "Your tanning supplies have been stored"			Int Button = MRW_CraftingMainMessageBox.Show()					If Button == 0			Player.RemoveItem(MRW_CraftingList,Counter0,True,Self)				Notification(CraftingStored)		EndIf				If Button == 1			If Counter1 < 1					Notification(NoSmeltingSupplies)				Return CraftingMenu()				Else					Player.RemoveItem(MRW_SmeltingList,Counter1,True,Self)					Notification(SmeltingStored)				Return CraftingMenu()				Endif		EndIf				If Button == 2			If Counter2 < 1					Notification(NoTanningSupplies)				Return CraftingMenu()				Else					Player.RemoveItem(MRW_TanningList,Counter2,True,Self)					Notification(TanningStored)				Return CraftingMenu()				Endif		EndIfEndFunction

I have also tried to write it like this, but the same problem occurs:

Scriptname MRW_CraftingStorage_Simple extends ObjectReference  {This script only stores crafting supplies}	Import Utility	Import Game	Import Debug	Message Property MRW_CraftingMainMessageBox auto	FormList Property MRW_CraftingList auto	FormList Property MRW_SmeltingList auto	FormList Property MRW_TanningList auto		Int Counter1	Int Counter2	Int PlayerInventory	Event OnActivate (ObjectReference akActionRef)		String NoCraftingSupplies = "You have no crafting supplies"		String NoSmeltingSupplies = "You have no smelting supplies"		String NoTanningSupplies = "You have no tanning supplies"		String SuppliesStored = "Your supplies have been stored"		Actor Player = GetPlayer()			PlayerInventory = Player.GetItemCount(MRW_CraftingList)			Counter1 = Player.GetItemCount(MRW_SmeltingList)			Counter2 = Player.GetItemCount(MRW_TanningList)		If PlayerInventory < 1			Return Notification(NoCraftingSupplies)		ElseIf akActionRef == Player			Int Button = MRW_CraftingMainMessageBox.Show()				If Button == 0														;Store Crafting			Player.RemoveItem(MRW_CraftingList,PlayerInventory,True,Self)				Return Notification(SuppliesStored)		EndIf				If Button == 1														;Store Smelting			If Counter1 < 1				Notification(NoSmeltingSupplies)					Else 				Player.RemoveItem(MRW_SmeltingList,PlayerInventory,True,Self)				Return Notification(SuppliesStored)			EndIf		EndIf					If Button == 2														;Store Tanning			If Counter2 < 1				Notification(NoTanningSupplies)					Else 				Player.RemoveItem(MRW_TanningList,PlayerInventory,True,Self)				Return Notification(SuppliesStored)			EndIf		Endif		EndIfEndEvent

Thanks in advance for any help/guidance

User avatar
Ron
 
Posts: 3408
Joined: Tue Jan 16, 2007 4:34 am

Return to V - Skyrim