Jump to content

Problem with OnMenuClosed script


icecreamassassin

Recommended Posts

so I'm setting up crafting stations that will loot a nearby supply container when you activate it and then will dump all the items on a specific FormList back into said container.

 

I tried putting all the code on the crafting station itself and it didn't work, and I also tried taking the code to return the items to the supply chests after exit on a "begin quest at start" script (yes I did remember to re-SEQ) but it also doesn't seem to trigger an event to return the items

FormList Property IngotsNOre Auto
FormList Property GemList Auto

ObjectReference Property SupplyChest1 Auto
ObjectReference Property SupplyChest2 Auto


ObjectReference Property CraftingTable Auto

Event OnInit()
    RegisterForMenu("CraftingMenu")
EndEvent
 
Event OnMenuClose(String MenuName)
    If MenuName == "CraftingMenu"
  if Game.GetPlayer().GetDistance(CraftingTable) <= 300
    int ItemCount1 = 0
    int ItemCount2 = 0

    If Game.GetPlayer().GetItemCount(IngotsNOre) > 0
        ItemCount1 = Game.GetPlayer().GetItemCount(IngotsNOre)
        Game.getPlayer().removeItem(IngotsNOre,ItemCount1,True,SupplyChest1)
    EndIf
    If Game.GetPlayer().GetItemCount(GemList) > 0
        ItemCount2 = Game.GetPlayer().GetItemCount(GemList)
        Game.getPlayer().removeItem(GemList,ItemCount2,True,SupplyChest2)
    EndIf
   endif
  endif
EndEvent
Edited by icecreamassassin
Link to comment
Share on other sites

  On 8/24/2014 at 6:00 AM, icecreamassassin said:

 

so I'm setting up crafting stations that will loot a nearby supply container when you activate it and then will dump all the items on a specific FormList back into said container.

 

I tried putting all the code on the crafting station itself and it didn't work, and I also tried taking the code to return the items to the supply chests after exit on a "begin quest at start" script (yes I did remember to re-SEQ) but it also doesn't seem to trigger an event to return the items

FormList Property IngotsNOre Auto
FormList Property GemList Auto

ObjectReference Property SupplyChest1 Auto
ObjectReference Property SupplyChest2 Auto


ObjectReference Property CraftingTable Auto

Event OnInit()
    RegisterForMenu("CraftingMenu")
EndEvent
 
Event OnMenuClose(String MenuName)
    If MenuName == "ContainerMenu"
  if Game.GetPlayer().GetDistance(CraftingTable) <= 300
    int ItemCount1 = 0
    int ItemCount2 = 0

    If Game.GetPlayer().GetItemCount(IngotsNOre) > 0
        ItemCount1 = Game.GetPlayer().GetItemCount(IngotsNOre)
        Game.getPlayer().removeItem(IngotsNOre,ItemCount1,True,SupplyChest1)
    EndIf
    If Game.GetPlayer().GetItemCount(GemList) > 0
        ItemCount2 = Game.GetPlayer().GetItemCount(GemList)
        Game.getPlayer().removeItem(GemList,ItemCount2,True,SupplyChest2)
    EndIf
   endif
  endif
EndEvent

Have you gone through the usual debug.notifications to verify that the event isn't triggering/found the exact location of where the bug is occuring?

Link to comment
Share on other sites

Also I see what you are trying to do and if you get it to work great btw good idea

 

Another way is to actually just make a trigger box and do a ontriggerenter and ontriggerleave and put it around your crafting table

Similar effect, different easier (imo) approach

Maybe :P

Just throwing ya a idea, I'm the king of fubaring my way around getting something to work in the CK lol

Link to comment
Share on other sites

Hello icecreamassasin,

 

I'm not 100% sure of a solution but I have some suggestions. Firstly, I notice that you have only registered for CraftingMenu and not ContainerMenu. Perhaps you should register for both?

 

Secondly, I had simmilar problems and ended up using the following code in conjunction with an OnMenuClose event:

Event OnKeyDown(Int aiKey)
	If UI.IsMenuOpen("InventoryMenu")
		bUpdateFavorites = True
		PlayerRef.RemovePerk(PRUFEICrafting)
	EndIf
EndEvent

You could check out my PRUFEI mod for a working example.

 

Regards,

--QC

Edited by quixoticynic
Link to comment
Share on other sites

I have Container menu registered via another function in my mod which is running all the time already, but containers don't come into play here as far as menus are concerned.

 

The trigger box would be an ok solution if I set it to OnTriggerLeave but how would I condition it out so it wouldn't rob the player of their ingots and ore every time they walk away from the forge? Plus the supply chest is close enough and in such a place that the player couldn't grab some to sell or for a quest for example and walk away because the trigger box would pick his pocket as he walks away lol. I suppose what I could do is set up a global to be set to 1 when you activate the craft station and have the trigger box set it back to 0 and use 1 as a condition for robbing you... that could work...

 

My only concern with this is that I have concerns using trigger boxes because I have several people experiencing an issue with a trigger box I have in several places in my mod. It's set up to disable itself when you enter it and each has a static display set to enable parent opposite of that trigger and while it works perfectly for me, several people it doesn't even function for. I suspect some conflict but I am using the vanilla script for the trigger box and it still doesn't seem to work for a few people.

Link to comment
Share on other sites

As near as I can tell this script is not going to do anything based on the crafting menu ever. The only time any of those functions will ever fire is when the container menu closes. Replace ContainerMenu with CraftingMenu in the first if line.
Link to comment
Share on other sites

  • Recently Browsing   0 members

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