Is there a way to make events erase other events?

I want an event to erase other events on the map and itself when i win a battle, and of course they should reappear when I come back to the map, is that possible?
I'd just use a global switch that gets turned on when you win the battle and off when you enter the map. To do that, you'd use an autorun event turning the switch off and then erase event.
I think you could use this script call to achieve what you want:
Code:
$gameMap.eraseEvent(eventId);

Original thread: https://forums.rpgmakerweb.com/threads/is-there-a-way-to-make-events-erase-other-events.149173/