User Tools

Site Tools


building:scripts:events:variable_based

This is an old revision of the document!


Variable Based Events

Those events will run only run for a specific object so they are optimal and should be your preferred way to register an event.

Registering / Unregistering a variable Event

As you can guess, it is using local variables, for example:

Will cause the myerf_useitem script to be called when the item on which the variable is set is used.

You can also register multiple script to the same event:

With the variables above, all scripts (myerf_useitem, myerf_useitem2, myerf_useitem3 and myerf_useitem4) will run when the item is used.

You can register / unregister a variable event dynamically with the following functions:

void RegisterVariableEvent(object oObject, string sEvent, string sScript, int bNoByPass=FALSE);
void UnregisterVariableEvent(object oObject, string sEvent, string sScript);

Creating / Running a Variable Based Event

You can trigger a variable event on an object by calling one of those functions:

int RunVariableEvent(object oObject, string sEvent);
int RunVariableEventWithParams(object oObject, string sEvent, array aParams);

They will return TRUE if the BypassVariableEvent() was calling during the execution of one of the registered scripts.

building/scripts/events/variable_based.1552277914.txt.gz · Last modified: 2019/03/11 04:18 by Mavrixio

phpBB Appliance - Powered by TurnKey Linux