SetEventHandler
Revision as of 22:00, 3 January 2012 by imported>8asrun6aer (Created page with "A command for Oblivion Script Extender '''Syntax:''' (success:bool) SetEventHandler eventID:string functionScript:ref filter1:pair fil...")
A command for Oblivion Script Extender
Syntax:
(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. Two optional arguments can be supplied as key::value pairs to filter events according to the target and/or object.
For more details on events and for a list of available events to hook into, see OBSE Command Documentation for events.
Example
scn FnOnHitByPlayer ref target ref attacker begin Function { target, attacker } ; we know the attacker must be the player, but the argument is still required print $target + " was hit by the player" end ------------- scn FnOnPlayerRestoreHealth ref target long effectCode begin Function { target, effectCode } print "The player has been hit by a restore health effect" end -------------- scn FnOnLoadGame string_var filename begin Function { filename } print "Loading game from " + $filename end --------------- scn SomeQuestScript begin gamemode if getGameRestarted SetEventHandler "OnHit" FnOnHitByPlayer object::PlayerRef SetEventHandler "OnMagicEffectHit" FnOnPlayerRestoreHealth ref::PlayerRef object::"REHE" SetEventHandler "LoadGame" FnOnLoadGame endif end
Notes
- When compiling scripts with this function, CS may generate a "expected string" error for the "filter" arguments. Generally, this error can be ignored if the script still successfully compiles. Be sure to run a live test of any script to ensure it runs in-game successfully.