MV Yanfly Event Chase Player help

I was wondering if there was a way to play a common event once the player leaves the event's sight? What I want to do is when the event sees the player, I want it to play music and turn a switch on. I can do that already, but when the event can no longer see the player, I want to turn the music off along with the switch. Thanks!
Open the plugin with a text editor. On line 106, hit Enter to make a new line and paste in:
Code:
 *  this._lostCommonEvent = x This event will play when player is lost.

Then go to line 189, make new line, and paste:
Code:
  this._lostCommonEvent = 0;

Go to line 394, make a new line, and paste:
Code:
    if (this._lostCommonEvent)
        $gameTemp.reserveCommonEvent(this._lostCommonEvent);
Moved to: Plugin Support
Open the plugin with a text editor. On line 106, hit Enter to make a new line and paste in:
Code:
 *  this._lostCommonEvent = x This event will play when player is lost.

Then go to line 189, make new line, and paste:
Code:
  this._lostCommonEvent = 0;

Go to line 394, make a new line, and paste:
Code:
    if (this._lostCommonEvent)
        $gameTemp.reserveCommonEvent(this._lostCommonEvent);
Thank you! I ended up having to put the last line of code 2 lines down, after the "if (!this._returnAfter) return;" thing. I know hardly anything about coding languages, so for some reason putting the code two lines down just kinda worked?? Thanks again, I can finally have my cringe chase sequence work right!
Thank you! I ended up having to put the last line of code 2 lines down, after the "if (!this._returnAfter) return;" thing.
What do you mean you "had to"? Changing that means that your common event will only run if you have told the event to return to its original position. Where I put it, the event should run when the event loses sight of you, regardless of whether it's set to return or not.
What do you mean you "had to"? Changing that means that your common event will only run if you have told the event to return to its original position. Where I put it, the event should run when the event loses sight of you, regardless of whether it's set to return or not.
For whatever reason, nothing happens when it's in the original spot.
Huh. Well, if it works for you, I won't bother trying to troubleshoot it 😉
Huh. Well, if it works for you, I won't bother trying to troubleshoot it 😉
lol thanks again my cringe music can play during chases now :oops::oops::oops::oops::oops:

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-event-chase-player-help.141229/