Registered Events

From Sinfar

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'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 done with the 2 following functions:

void RegisterEvent(string sEvent, string sScript);

void UnregisterEvent(string sEvent, string sScript);

For example, the following line:RegisterEvent("pc_ev_death", "myerf_ev_pcdeath")... will cause the myerf_ev_pcdeath script to be called before and every time that the pc_ev_death is about to be executed.

The parameters can be accessed the same way as the original script and the caller will be the same.

Creating / Running a Script Based Event

If in the middle of a script you want to notify everyone interested by what is happening, you can use the [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:

  • int RunEvent(string sScript, object oTarget, array aParams);
  • int RunEventInt(string sScript, object oTarget, array aParams);
  • object RunEventObject(string sScript, object oTarget, array aParams);
  • string RunEventString(string sScript, object oTarget, array aParams);
  • float RunEventFloat(string sScript, object oTarget, array aParams);
  • effect RunEventEffect(string sScript, object oTarget, array aParams);
  • array RunEventArray(string sScript, object oTarget, array aParams);
  • dictionary RunEventDictionary(string sScript, object oTarget, array aParams);
  • vector RunEventVector(string sScript, object oTarget, array aParams);
  • location RunEventLocation(string sScript, object oTarget, array aParams);