Jump to content

OnUpdate() Speeding up over time


RedxYeti

Recommended Posts

Event OnUpdate()

Bool bIsInventoryMenuOpen = UI.IsMenuOpen("Crafting Menu")

	 If bIsInventoryMenuOpen  == True

		RegisterForSingleUpdate(2)

		Game.AdvanceSkill("alchemy", 18)

	
	Else
	
		UnregisterForUpdate()	


	EndIf


EndEvent

So im using this to add skills while the player is at a crafting table. The problem is, after an extended amount of time, say 5-10 minutes, the backlog of updates comes flooding in to the point where its like 3-4 updates a second. is there a better way to make the updates run at a more consistent time?

 

I dont want to use game time because everyone uses a different timescale.

 

any ideas?

Link to comment
Share on other sites

I've also noticed that the OnUpdate event doesn't work reliably while in menus. Instead, I would try a while loop:

 

Function AdvanceSkillInMenu() 
    While  UI.IsMenuOpen("Crafting Menu") 
        Game.AdvanceSkill("alchemy", 18)
        Utility.WaitMenuMode(2)
    EndWhile
EndFunction
Link to comment
Share on other sites

 

I've also noticed that the OnUpdate event doesn't work reliably while in menus. Instead, I would try a while loop:

 

Function AdvanceSkillInMenu() 
    While  UI.IsMenuOpen("Crafting Menu") 
        Game.AdvanceSkill("alchemy", 18)
        Utility.WaitMenuMode(2)
    EndWhile
EndFunction

 

 

 

Thank you for your reply, ive been using a while since i read your message but it was still stacking.

 

 

I finally figured out, the game must reactivate the crafting tables after a certain amount of time to see if the player is at them.

 

 

I found out with a message box and sure enough, after a set amount of time the message box would show up.

 

Event OnActivate(ObjectReference ReferenceAlias)


if (PlayerRef.GetSitState() != 3)


debug.messagebox("player is sitting already")


else
Registerforsingleupdate(1)
endif


endevent

thanks for your help im using a while and the menu wait as well :thumbsup: sorry it took so long to reply :tongue:

 

I looked for so long for a reason my code was running twice, I was certain something in my mod was activating it twice.

 

 

now i can finally remove the onupdate.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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