Background for Skyrim SE
Member of the Form script
voidfunctionRegisterForModEvent(stringeventName, stringcallbackName)Native

Description

Wiki Description

Registers a custom event callback for given event name. Registrations have to be refreshed after each game load.

Documentation Comment

Registers a custom event callback for given event name.
Registrations have to be refreshed after each game load.

Examples:
RegisterForModEvent("myCustomEvent", "MyModEventCallback")

Event signature of custom event callbacks:
Event MyModEventCallback(string eventName, string strArg, float numArg, Form sender)
endEvent


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.
  • ModEvent registrations are persistent and are stored in the MCBR record of the SKSE co-save. If you mod relies on these registrations being persistent it is strongly recommended that you register for the event again after each game load, if the user deletes this file for any reason it could break your mod.[1]

Parameters

  1. stringeventName

    CK Wiki Description

    The name of the event sent by SendModEvent.

  2. stringcallbackName

    CK Wiki Description

    The name by which you can catch the event.


Examples

; Register to receive the ModEvent:
; named HectorHitMe with the callback of OnHectorHitMe
RegisterForModEvent("HectorHitMe", "OnHectorHitMe")

Event OnHectorHitMe(string eventName, string strArg, float numArg, Form sender)
;Do something
EndEvent

Auto-Generated Example

string myString__eventName
string myString__callbackName

myForm__toCallFunctionOn.RegisterForModEvent(myString__eventName, myString__callbackName)

Related Pages


Additional References

View this function’s page on the Skyrim Creation Kit Wiki

Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.