[dismiss]
This wiki is a copy of the original Oblivion CS wiki created and maintained by the UESP.net. See CSwiki:Copy Notice for more info.
Difference between revisions of "SetEventHandler"
Jump to navigation
Jump to search
m
no edit summary
imported>8asrun6aer m (→Notes) |
imported>8asrun6aer m |
||
Line 4: | Line 4: | ||
(success:bool) SetEventHandler eventID:string functionScript:ref filter1:pair filter2:pair | (success:bool) SetEventHandler eventID:string functionScript:ref filter1:pair filter2:pair | ||
Registers a user-defined function as a handler for the specified event. If the function script returns a value, it will be ignored | Registers a user-defined function script as a handler for the specified event. If the user-defined function script returns a value, it will be ignored. | ||
For more details on events and for a list of available events to hook into, see [[ | Two optional arguments can be supplied to '''SetEventHandler''' by using the unique syntax of ''"key"''::''value'' pairs to filter events according to the target and/or object. The ''"key"'' part is a string (must be enclosed in quotes) and is generally expected to be either "ref" (generally referring to the target or first argument in your custom function) or "object" (generally referring to the source or second argument in your custom function), regardless of the names of the argument variables in your function script (exception: for OnHealthDamage, "object" refers to the damaged actor). | ||
For more details on events and for a list of available events to hook into, see [[Event Handler Functions]]. | |||
== Example == | == Example == | ||
Line 44: | Line 46: | ||
begin gamemode | begin gamemode | ||
if getGameRestarted | if getGameRestarted | ||
SetEventHandler "OnHit" FnOnHitByPlayer "object":: | SetEventHandler "OnHit" FnOnHitByPlayer "object"::Player | ||
SetEventHandler "OnMagicEffectHit" FnOnPlayerRestoreHealth "ref":: | SetEventHandler "OnMagicEffectHit" FnOnPlayerRestoreHealth "ref"::Player "object"::"REHE" | ||
SetEventHandler "LoadGame" FnOnLoadGame | SetEventHandler "LoadGame" FnOnLoadGame | ||
endif | endif | ||
Line 51: | Line 53: | ||
</pre> | </pre> | ||
With the the above four scripts compiled and loaded and the quest script ''SomeQuestScript'' activated, you should then see the following new effects in game: | |||
# Whenever the player hits another actor, that actor will be knocked back 50 feet/units. | |||
# Whenever the "REHE" magic effect is applied to the player, you should see a message: "The player has been hit by a restore health effect" | |||
# Whenever a game is loaded, you should see a console message: "Loading game from ''filename''" | |||
==Notes== | ==Notes== | ||
'''none''' | '''none''' |