RegisterForCustomEvent - ScriptObject
Jump to navigation
Jump to search
Member of: ScriptObject Script
Registers this script to receive the specified custom event from the source object whenever that source object sends the event. The event will be relayed only to this script and will not be sent to other scripts attached to the same object, or to any aliases or magic effects attached to the object.
Syntax[edit | edit source]
Function RegisterForCustomEvent(ScriptObject akSender, CustomEventName asEventName) native
Parameters[edit | edit source]
- akSender: The ScriptObject that receives the event we want to also receive.
- asEventName: The event we want relayed to us. This must be a raw string literal and may not be a variable.
Return Value[edit | edit source]
None
Examples[edit | edit source]
; AmbushTriggerScript defines the Ambush custom event
AmbushTriggerScript Property kTrigger Auto Const
Event OnInit()
; Register for Ambush event from the trigger - note the trigger type is the script type that defines the event
RegisterForCustomEvent(kTrigger, "Ambush")
EndEvent
; Special event to receive when the ambush event is received from a AmbushTriggerScript script
; Note the type in the event name matches the type of the first parameter, and is also the script where the
; custom event is defined.
Event AmbushTriggerScript.Ambush(AmbushTriggerScript akSender, Var[] akArgs)
Debug.Trace("We received the ambush event from " + akSender + " with arguments " + akArgs)
EndEvent
Notes[edit | edit source]
- Aliases and quests will automatically unregister for this event when the quest stops. Active magic effects will automatically unregister when they are removed.
- The object type in the custom event definition must be the script where the event was originally defined. For example, if the AmbushTriggerScript sends the Ambush event, you must use that and not ObjectReference, which doesn't define the event.