Difference between revisions of "SendCustomEvent - ScriptObject"
Jump to navigation
Jump to search
imported>Plplecuyer |
m (Correct Parameter Name (asEventName --> asEvent)) |
||
| Line 8: | Line 8: | ||
== Syntax == | == Syntax == | ||
<source lang="papyrus"> | <source lang="papyrus"> | ||
Function SendCustomEvent(CustomEventName | Function SendCustomEvent(CustomEventName asEvent, Var[] akArgs = None) native | ||
</source> | </source> | ||
== Parameters == | == Parameters == | ||
* | *asEvent: The event to send. This must be a raw string literal and may not be a variable. | ||
*akArgs: The array of arguments to send to the receivers. | *akArgs: The array of arguments to send to the receivers. | ||
**'''Default''': None | **'''Default''': None | ||
Latest revision as of 22:23, 19 January 2025
Member of: ScriptObject Script
Sends the specified custom event to any scripts that have registered for it. The event must be defined in our script or in one of our parent scripts. This function returns immediately, not waiting for any of the receivers.
Syntax[edit | edit source]
Function SendCustomEvent(CustomEventName asEvent, Var[] akArgs = None) nativeParameters[edit | edit source]
- asEvent: The event to send. This must be a raw string literal and may not be a variable.
- akArgs: The array of arguments to send to the receivers.
- Default: None
Return Value[edit | edit source]
None
Examples[edit | edit source]
; Define the custom event "Ambush" in this script
CustomEvent Ambush
Event OnActivate(ObjectReference akSource)
; Send the Ambush event to anyone listening with no arguments
SendCustomEvent("Ambush")
; Send the Ambush event with two arguments
Var[] kargs = new Var[2]
kargs[0] = akSource
kargs[1] = 4.2
SendCustomEvent("Ambush", kargs)
endEventNotes[edit | edit source]
- The event you send must be defined using "CustomEvent <name>" somewhere in your script (outside a function, property, or event definition) before you can send it, and before anyone else can register for it.
- This function returns immediately, the receivers receiving the event as if it was a game event and running their events in parallel. It will not wait for those receivers (if any) to finish running their event blocks.