Jump to content

RegisterForSingleUpdateGameTime Not Working


Recommended Posts

I'm trying to use this function to control time between uses of a scripted item. For some reason it just won't work at all. Here's a shortened version of the script:

Event OnEquipped(Actor AkActor)
  If(Waiting == False)
   Game.DisablePlayerControls(false, false, False, false, false, True, false, False)
   ;Doing Stuff
   Waiting = true
   Game.EnablePlayerControls()
   If(RegisterForSingleUpdateGameTime(1.0))
    Debug.Notification("Update Should Be Registered")
   Else
    Debug.Notification("Update Did Not Register!")
   EndIf
  Else
   Debug.Notification("You have already used this today")
  EndIf
EndEvent

Event OnUpdateGameTime()
Waiting = False
Debug.Notification("Update Completed")
EndEvent

Whenever I test it it shows that it did not register, meaning that the issue is with the function not the event. Does anyone know why? I cant figure out what I could be doing wrong :wallbash:

Edited by HeirOfTheSeptims
Link to comment
Share on other sites

You cannot use this code

   If RegisterForSingleUpdateGameTime(1.0)
   Else
   EndIf

because the native function RegisterForSingleUpdate() does not return any variable like bool. So you'll get always the else branch.

 

some links for interest:

https://www.creationkit.com/index.php?title=OnEquipped_-_ObjectReference
https://www.creationkit.com/index.php?title=RegisterForSingleUpdateGameTime_-_Form

 

 

 

; https://forums.nexusmods.com/index.php?/topic/10108013-registerforsingleupdategametime-not-working/

  Bool Waiting        ; [default=False]

EVENT OnEquipped(Actor akActor)
    IF ( Waiting )        ; == TRUE
        Debug.Notification("You have already used this today!!")
    ELSE                ; == False
        Waiting = TRUE                ; *T*
        Game.DisablePlayerControls(False, False, False, False, False, True, False, False)
;       ----------------------

           ; ... doing Stuff here

;       ----------------------
        Game.EnablePlayerControls()
        
        RegisterForSingleUpdateGameTime(1.0)              ; (1.0) one hour to wait, (24.0) one day to wait(as in-game hour)
        Debug.Notification("Update has been registered.")
    ENDIF
ENDEVENT


EVENT OnUpdateGameTime()
    Waiting = False                   ; ***
    Debug.Notification("Update Completed!")
ENDEVENT

 


Sometimes its a good idea to look into original source files or Skyrim wiki.

Edited by ReDragon2013
Link to comment
Share on other sites

  • Recently Browsing   0 members

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