RegisterForRemoteEvent - ScriptObject
Jump to navigation
Jump to search
Member of: ScriptObject Script
Registers this script to receive the specified event from the source object whenever that source object receives the event. Calling the event directly on the source object will not relay the event to this script. 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 RegisterForRemoteEvent(ScriptObject akEventSource, ScriptEventName asEventName) native
Parameters[edit | edit source]
- akEventSource: 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]
Event OnInit()
; Register for Activate event from the secret door
RegisterForRemoteEvent(SecretDoor, "OnActivate")
EndEvent
; Special event to receive when the door is activated
; Note the type in the event name matches the type of the first parameter, and is also the script where the
; event is originally defined.
Event ObjectReference.OnActivate(ObjectReference akSender, ObjectReference akActionRef)
Debug.Trace(akSender + " was activated by " + akActionRef)
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 event will be sent to an event in this script named "<object type>.<event name>" which will accept the same parameters as the desired event, and also a sender parameter.
- The object type in the remote event definition must be the script where the event was originally defined. For example, if you wanted to get the OnActivate event, you would use ObjectReference, even though Actor also can receive the event (it inherits the event from ObjectReference). The compiler should give you an appropriate error and suggestion to fix if the type is incorrect.