CallAfterSeconds

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender version 6.1.

Description

Executes a User Defined Function or an inline Lambda script after specified amount of seconds have elapsed in-game.

Only runs in GameMode by default, or if runWhen is set to 0. If runWhen is set to 1, will also run in MenuMode. If it is set to 2, will also pause the callback while the main menu / pause menu / console menu MenuModes are open (new in 6.3.0).

Every queued call is removed when loading the game (GetGameLoaded), so they may need to be reset during then.

  • NOTE: This means that timers created using this function are NOT savebaked, which could potentially cause bugs if a timer was expected to keep running after saving and reloading a save while the timer was running.

Arguments can be passed like Call to the function (since xNVSE 6.2.6). If an arg is an array, then its lifetime will be extended until the callbacks have stopped.

Syntax

[help]
reference.CallAfterSeconds seconds:float udf:script runWhen:int{0} multi:arg(up to 15) 

Or:

reference.CallAfter seconds:float udf:script runWhen:int{0} multi:arg(up to 15) 

Example with an inline Lambda script

CallAfterSeconds 10 (begin function {}
    print "10 seconds later..."
end)

Or

CallAfterSeconds 5.5 ({} => print "5.5 seconds later...")

Calls UDF after 5.5 seconds, but only in GameMode. See Lambda.

Example with a UDF

scn MyUDF
Begin Function { ref rPlayer }
    print "5.5 seconds later... My name is " + $rPlayer
End
CallAfterSeconds 5.5 MyUDF 1 PlayerRef

Notes

  • The seconds are not counted in real-life seconds; they are affected by the game's Time Mult (GetGlobalTimeMultiplier).
    • The time mult affects the callback even while inside MenuMode.
  • If you pass 0 as an argument for seconds, the callback is called next frame. This is similar behaviour to CallFunctionNextFrame.

See Also