ModEvent Script

From Creation Kit
Jump to: navigation, search

Minimum required SKSE Version: 1.7.0

Script for ModEvents.


ScriptName ModEvent Hidden

SKSE Global Functions

Int Create(String eventName)
  • Creates a new ModEvent and returns the handle.
Bool Send(Int handle)
  • Sends the ModEvent and releases it. (Return value indicates whether it was successfully sent).
Bool Release(Int handle)
  • Releases the ModEvent without sending it.
PushBool(Int handle, Bool value)
  • Pushes a Bool param into the event.
PushInt(Int handle, Int value)
  • Pushes a Int param into the event.
PushFloat(Int handle, Float value)
  • Pushes a Float param into the event
PushString(Int handle, String value)
  • Pushes a String param into the event.
PushForm(Int handle, Form value)
  • Pushes a Form param into the event.


Script that is sending the event:

    int handle = ModEvent.Create("ModPrefix_myCustomEvent")
    if (handle)
        ModEvent.PushForm(handle, self)
        ModEvent.PushForm(handle, someOtherForm)
        ModEvent.PushInt(handle, 1000)
        ModEvent.PushString(handle, "It worked!")

Script that wishes to receive the event:

Function OnInit()
    RegisterForModEvent("ModPrefix_myCustomEvent", "OnMyCustomEvent") ;(remember to re-register for events each game reload)
;note that the parameters of this event must match the number & order of parameters as they were pushed in the sending script.
Event OnMyCustomEvent(Form sender, Form theForm, int theInt, string theString)
    if (sender as Actor)
        debug.trace("Our event was received from a script attached to an Actor!")
    int goldVal = someOtherForm.GetGoldValue()
    debug.trace("The other form recieved by our event has a gold value of " + goldVal)
    debug.trace("We recieved theInt, and it equals " + theInt)
    debug.trace(theString) ;prints "It worked!"