<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.sinfar.net/index.php?action=history&amp;feed=atom&amp;title=Registered_Events</id>
	<title>Registered Events - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.sinfar.net/index.php?action=history&amp;feed=atom&amp;title=Registered_Events"/>
	<link rel="alternate" type="text/html" href="https://wiki.sinfar.net/index.php?title=Registered_Events&amp;action=history"/>
	<updated>2026-04-09T04:58:20Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://wiki.sinfar.net/index.php?title=Registered_Events&amp;diff=913&amp;oldid=prev</id>
		<title>ItsABadger: Created page with &quot;=== Script Based Events === Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn&#039;t matter, but if you want to do something only when something happen to a specific object, you should use the Variable Based Event system.  === Registering / Unregistering a Script Based Event === This is d...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.sinfar.net/index.php?title=Registered_Events&amp;diff=913&amp;oldid=prev"/>
		<updated>2025-03-05T13:29:24Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=== Script Based Events === Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn&amp;#039;t matter, but if you want to do something only when something happen to a specific object, you should use the &lt;a href=&quot;/index.php/Variable_Based_Events&quot; title=&quot;Variable Based Events&quot;&gt;Variable Based Event&lt;/a&gt; system.  === Registering / Unregistering a Script Based Event === This is d...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Script Based Events ===&lt;br /&gt;
Those events are tie to a script name/ResRef they will run whenever the script that they are registered to is called. It is good to change the behaviour or a specific script by bypassing it or when the caller doesn&amp;#039;t matter, but if you want to do something only when something happen to a specific object, you should use the [[Variable Based Events|Variable Based Event]] system.&lt;br /&gt;
&lt;br /&gt;
=== Registering / Unregistering a Script Based Event ===&lt;br /&gt;
This is done with the 2 following functions:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;void RegisterEvent(string sEvent, string sScript);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;void UnregisterEvent(string sEvent, string sScript);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example, the following line:&amp;lt;code&amp;gt;RegisterEvent(&amp;quot;pc_ev_death&amp;quot;, &amp;quot;myerf_ev_pcdeath&amp;quot;)&amp;lt;/code&amp;gt;... will cause the myerf_ev_pcdeath script to be called &amp;#039;&amp;#039;&amp;#039;before&amp;#039;&amp;#039;&amp;#039; and every time that the pc_ev_death is about to be executed.&lt;br /&gt;
&lt;br /&gt;
The parameters can be accessed the same way as the original script and the caller will be the same.&lt;br /&gt;
&lt;br /&gt;
=== Creating / Running a Script Based Event ===&lt;br /&gt;
If in the middle of a script you want to notify everyone interested by what is happening, you can use the [[https://nwnlexicon.com/index.php?title=ExecuteScript%7CExecuteScript Execute Script]] function, but better, you can use the RunEvent(ReturnType) functions, which will create a script based event that can be registered, have parameters and a return value:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;int RunEvent(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;int RunEventInt(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;object RunEventObject(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;string RunEventString(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;float RunEventFloat(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;effect RunEventEffect(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;array RunEventArray(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;dictionary RunEventDictionary(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;vector RunEventVector(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;location RunEventLocation(string sScript, object oTarget, array aParams);&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>ItsABadger</name></author>
	</entry>
</feed>