MV Running a common event on file load, bypassing all running events

Hey, I'm making a visual novel, which means events are running 24/7 with very few exceptions

I really want to add something similar to Undertale's Dogcheck, a feature that blocks you from loading the game if some variables have unusual values (for example map id is set to a number that usually shouldn't be accessible)

My first idea was to use Yanfly's utility common events plugin to run a common event on every save load, but the common event only runs after all other events are off, which defeats the whole purpose because, like i said, there's an event running 99% of the time.

Note: I don't want to end all running events, I still want them to run after the check (common event called on file load) is done. (If it detects unusual variable values it'll never stop running anyway, since it's supposed to be a looped animation)

Is there a way to make this common event bypass all other events and run before the usual event loads? Is there some kind of event running priority?
Or maybe I should run this variable check from the game itself, and not the save file?
Thanks in advance!
There might be a plugin for that
I imagine that’s why this is posted in JS Plugin Requests. @Raycat2011
Events runs by their ids so the first autorun event runs first.
In one of my games I have hundreds of maps but I always copy an event from the template map once it is created. I could have used a plugin but since it works I don't want to change.

Edit*
Since you are already using YEP's common event plugin, you can check $gameTemp._commonEventId in that auto start event.
For example, your common event is 8, you can check if gameTemp._commonEventId==8 in a conditional branch.
So you don't have to put anything in common event 8, just use it to check.
I've checked if it runs but sadly it doesn't, not until the autorun event stops

I've been thinking about it and I came up with a different idea:
Basically, you can only save the game via a choice (so i can easily control when the player is able to save the game), and there's no option to save when there's no event running
So, I'll run the common event that checks variables right after every save command you can possibly save your game with.

That way, everytime you load into your save file, the variable check will be executed

I guess it can also be used as a basic anti-cheat, given that the player level, money, etc were saved in a group of variables before saving. The check will compare these variables to actual values, and if they're different, that means the save file was edited between being saved and loaded
There is a plugin called SwitchOnLoad that ships with RPG Maker MV. For the Steam version (I assume something similar applies for the standalone version) it can be found in the install folder:
  • RPG Maker MV/dlc/KadokawaPlugins/SwitchOnLoad.js
E.g. you could make a Parallel common event bound to a certain switch, then have the plugin turn that switch on when a save is loaded. If the last command in the event turns the switch off again, the event will run once, without waiting for other events (because it is Parallel), whenever you load the game.
There is a plugin called SwitchOnLoad that ships with RPG Maker MV. For the Steam version (I assume something similar applies for the standalone version) it can be found in the install folder:
  • RPG Maker MV/dlc/KadokawaPlugins/SwitchOnLoad.js
E.g. you could make a Parallel common event bound to a certain switch, then have the plugin turn that switch on when a save is loaded. If the last command in the event turns the switch off again, the event will run once, without waiting for other events (because it is Parallel), whenever you load the game.

This sounds like the perfect way to do it, now that I think about it

Though there is 1 issue, the choice box from the usual autorun event still persists, even if the parallel event is triggered... and I have no idea how to terminate it lol
I'm not sure if I understand you correctly.
Maybe you can add a conditional branch in that even so it doesn't show choice?
Or, if it's save points only, just put the entire "on load" thing in the save point event instead. Like:
  • Open Save Screen
  • If {Game Loaded} is ON:
    • Text: Game was loaded!
    • Switch {Game Loaded} OFF.
    Else:
    • (Just continue the event.)
If you want more specific advice then we'd need to see this "autorun event" of yours.
I think it'd be easier to simply call the event after every opportunity to save

I can't really put the autorun event in question in a branch, because there's like 300 of them, each for 1 map, since you can actually move between them

I think I'll go with calling the event manually, but thanks for the help anyways!
The problem is even if you run the event before others, you don't have a way to stop other event from running if you don't add branches.
Unless, you want to halt the game if you detect something, for example, jump to another map or return to the title screen.
My idea was to simply loop an animation, which would make the event never-ending in case it detects something. Which means that the autorun event will never run, because the called common event never stops
Which means that the autorun event will never run, because the called common event never stops
common event autoruns only work if you have a switch ON (global switch from databse).
so you can basicly turn this switch OFF at the end of the event.

if you want to run this common event, loading the game on success is turn this
switch ON and OFF inside the common event.

Original thread: https://forums.rpgmakerweb.com/threads/running-a-common-event-on-file-load-bypassing-all-running-events.175406/