Background for Fallout 4
Member of the ScriptObject script
boolfunctionRegisterForRemoteEvent(ScriptObjectakEventSource, stringasEventName)Native

Description

Wiki Description

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.

Documentation Comment

Register for the specified event from the specified source. Event must be one sent by
the game itself, and not an event defined in ScriptObject. The event will be sent to:
Event .( akSender, )
For example, OnDeath on an Actor would be:
Event Actor.OnDeath(Actor akSender, Actor akKiller)
But OnDeath on a reference alias would be:
Event ReferenceAlias.OnDeath(ReferenceAlias akSender, Actor akKiller)
Returns true if the registration succeeded


Caveats

CK Wiki - Notes

  • 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.

Parameters

  1. ScriptObjectakEventSource

    CK Wiki Description

    The ScriptObject that receives the event we want to also receive.

  2. stringasEventName

    CK Wiki Description

    The event we want relayed to us. This must be a raw string literal and may not be a variable.


Examples

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

Auto-Generated Example

ScriptObject myScriptObject__akEventSource
ScriptEventName (string[]) myScriptEventName (string[])__asEventName

bool returnedValue = myScriptObject__toCallFunctionOn.RegisterForRemoteEvent(myScriptObject__akEventSource, myScriptEventName (string[])__asEventName)

Related Pages


Additional References

View this function’s page on the Fallout 4 Creation Kit Wiki

Some data provided by the Fallout 4 Creation Kit Wiki. Licensed under the Creative Commons Attribution-Share Alike 4.0 license.