SetEventHandler

From GECK

A function added by the New Vegas Script Extender.

Description

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.

Syntax

(success:bool) SetEventHandler eventID:string functionScript:ref filter1:pair filter2:pair

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

See Also

Personal tools