Permanently Erase Events With One Event Command

I've been wondering, is it possible to erase events with just one event command?

Currently, the way I permanently erase events is by creating a blank page with erase event command in that event with a set switch. And if that switch is turned on, the event then will permanently deleted. (AFAIK)
However, I reckon by doing so will leave me with a tons of switches to manage in the future. So, I'm hoping for any methods that are more practical if possible.

Thank you very much for your help 🙂
I think there are other things that affect the performance of your program far more than a simple switch or self switch.

No event is permanently deleted. Every event is loaded when the map is loaded. Then if you have some set to erase self, they will be deleted. You don't have to "manage" a switch. The program already manages them for you.

My suggestion is to put your efforts into other more significant things.
@curioushika At the end of the second to last page of the event to be "erased", set Self Switch D (unless you already used it, in which case, you make a new switch). Make the last page of the event require Self Switch D (or the switch you made), and leave it blank. The event will technically always be there, but never run again. No new switches need be created unless you've gone through all Self Switches. What Shaz said is correct:

No event is permanently deleted. Every event is loaded when the map is loaded. Then if you have some set to erase self, they will be
[temporarily]
[until the map loads again...]
leaving the event there like that will still cause it to be checked every time the map needs a refresh, to see if the same page should be active. It will also cause the event's location to be checked every time the player, or another event, moves from one tile to another. So there's an overhead in keeping it around, even though it's not "doing" anything.

Setting it to parallel process with Erase Event will cause a little extra processing when the map first loads, but the event will not be checked again until the map is reloaded.
I'm sorry that I didn't made the post clearly. I understand that an event can't be literally permanently erased, which is why I used this method at the moment.

The method that I use is quite similar with what @mathmaster74 suggested. For example:
I made a cutscene which involves Event A, B and C. Event A is what trigger & control the cutscene. After the said cutscene done, I want to erase all of the events. Erasing Event A is simple by using self-switch and then create a second page that uses command Erase Event with Autorun. But AFAIK, to erase event B & C, I have to create and turn on a new switch (which I meant by "manage") in both events.

The problem with this method is, every time I want to erase an event, I have to create & turn on new switch. If I want to delete event B & C one by one, I have to make 2 switches, which means there will be 2 switches per event. I reckon the number will increase exponentially because I intend to make quite a lot of cutscenes.

tl;dr What I want really want to ask is, is there any way to trigger self-switch by just 1 event command? I believe it's unlikely, so any suggestions to "erase" event efficiently are welcome.
You can turn on one event's self switch from another event. Just use the Outer Self Switches plugin, which I believe ships with the engine (if not in the default plugins for a new project, possibly in the DLC), or do it directly in a script command. If your map is 15, and your cutscene event is 8, and you want to turn on self switch A for events 9 and 10, just do this:
Code:
$gameSelfSwitches.setValue([16, 9, 'A'], true);
$gameSelfSwitches.setValue([16, 10, 'A'], true);

And use a parallel process trigger, not an autorun. Only one autorun can run at a time, but several parallel process events can run at the same time. The way you're doing it, you could be in a situation where you have a REAL cutscene that needs to play when you enter a map, and 3 events that delete themselves, and the 3 events won't delete themselves until after the cutscene has finished.
and why do you even want to erase those events?

Events alone, especially events that do nothing, have only minimal effect on a game. It doesn't matter for the performance if there are one or two dozen events around.
In fact you're creating more problems and losses with your insistence on deleting those events than they could ever cause by themselves.

Yes, there are some cases where events are better deleted - but that is such a low number that the number of switches for it doesn't matter for the game.

So I'm wondering on why you think you need to do this.
@Shaz Thank you so much. 🙂 That looks quite like what I want, and the plugin is already included indeed, so I will check it soon.

@Andar That's true, but I need this to tidying up the map after a cutscene that happens in that particular map ends.
For example:

https://i.imgur.com/yKyMqAN.png

In that picture there are 6 events that involved in a cutscene, and they're not doing anything indeed, but if I don't erase it, they will still linger in there even after the player re-enter the map, which will make it look awkward.
Most tutorials that I have watched only show how to make the cutscenes, but not tidying up afterwards, so this is the only way that I can think of at the moment.
Here a few more examples of that Codeline for self switch.

Current Map, Self Event, A ,On
$gameSelfSwitches.setValue([$gameMap.mapId(), this._eventId, 'A'], true)

Current Map, Event 5, A, On
$gameSelfSwitches.setValue([$gameMap.mapId(), 5, 'A'], true)

You could also specifie the Event Id by a Variable
$gameSelfSwitches.setValue([$gameMap.mapId(), $gameVariables.value(1), 'A'], true)

Edit:
In the Scriptcall list is also the command for erasing event ids.
but the problem is after mapreload they would be back, so the solution with extra eventpage is good i think.

$gameMap.eraseEvent(this._eventId);
$gameMap.eraseEvent(5);
$gameMap.eraseEvent(12);

https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mv-script-call-list.46456/

Edit2:
I would not erase them, just turn on there last eventpage with self switch command and dont forget to mark the "through", else other events cant move over them.
Best solution even if the map reloads. But i agree using a extra switch for every event would be overkill =).
but not tidying up afterwards, so this is the only way that I can think of at the moment.
Those events are usually switched off to a page that has no sprite and is at above priority (or through as said above), no need to erase them.
Another trick would be to condition them to the cutscene - that would be one switch for the total group of events.
Just make one switch "cutscene active" and condition all their event pages (or their only page if they don't need anything else) to that switch. If no page is active then the events will also vanish, so a switch like that will only make them appear if that switch is ON, and you do that only when the cutscene needs them.
@Bex I see. Thanks for the suggestion ☺️

@Andar Tying all the events to one switch seems the most efficient idea I've heard so far. Although I think it'd be a problem if there are multiple events that appear and gone in the same area in the map. For example if I want to remove event A first and event B afterwards, and both events are in the same map, if I turn the Event Switch off, both of them will be gone at the same time instead of one at a time.
But I think I'm going to try this for the time being. Thank you so much ☺️
For example if I want to remove event A first and event B afterwards, and both events are in the same map, if I turn the Event Switch off, both of them will be gone at the same time instead of one at a time.
a page has more conditions than one.
you can use a second switch condition for fine control of those events that will appear later, and they would still all vanish if you switch off the main switch because both switches need to be on if two switches are in the condition.

and a lot of people also use variables for fine control of larger segments, like a story step - each time the story proceeds the counter goes up and several things throughout the entire game will react to that counter variable and only happen if the player has progressed to that step of the story.
You could do what I do...I set aside switches 21 - 30 for cutscene control, and named them Scene I - X. Scene I is for the party members that need to be there for the cutscene, and I use Scene II and onwards if I need something to appear for a 2nd scene in the same area. Has worked really well, and in the end I never went past Scene IV.

Also for really long plot cutscenes I just transfer the player to a cutscene map that is used just for the cutscene. The player will not know the difference.
If you don't want events to load in return trips to the map after a cutscene, you could always use something like Yanfly's event spawner. Since they're spawned via function calls during the cutscene, they're not part of the permanent map data and will not reappear afterward. Now I don't know how well the whole thing works because honestly, this level of optimization just isn't necessary, but you could try it and see if it's what you're looking for.
@curioushika - At the risk of getting somebody angry, might I suggest killEvents.js?

To use it, just make a script call (replace event_id as neccessary):

Code:
pagpatay.an.killEvent(event_id);

e.g.
Code:
pagpatay.an.killEvent(1);

Deleted events are retained by save files.

I hope this helps 🙂
@Andar Thank you so much. This seems quite practical 🙂

@bgillisp Transferring the player into a cutscene map is a great idea. Thanks 😀

@Aesica Yanfly Event Spawner could be a viable option. Thanks for the suggestion 🙂

Original thread: https://forums.rpgmakerweb.com/threads/permanently-erase-events-with-one-event-command.109444/