The script attached to this event fires when an area, trigger, or encounter boundary is exited. This can be used for such effects as slaying all the zombies that just animated to kill the intruding tomb robbing PC or removing the Holy Grail from the PC's inventory and triggering a series of encounters that send creatures after the PC. Area of effects also can have On Exit events defined when they are created.
Something left the current area, encounter, trigger or area of effect (not necessarily a PC).
GetExitingObject() returns the object that just left the area, encounter, or trigger.
The OnExit event fires for an Area of Effect if it is dispelled or runs out of duration. For spells such as Acid Fog, it removes the slowing effect.
The OnExit event for trigger nor area of effect doesn't fire for player exiting the game. Also, the area OnExit event doesn't fire for dead player exiting the game. To workaround this, you need to store trigger/area object in OnEnter with local object variable, read it in OnClientLeave and ExecuteScript on this object from there.
// sends "HUNTER" home (aptly named "HUNTER_CAVE") if
// the PC leaves the area
object oExiting = GetExitingObject();
object oMonster = GetObjectByTag("HUNTER");
object oCave = GetObjectByTag("HUNTER_CAVE");
SetLocalObject(OBJECT_SELF, "PC_Entered", OBJECT_INVALID);
// if "HUNTER" is leaving while giving chase, send him home
if (oExiting == oMonster)