MZ Random encounters only active after a switch is ON?

Is there a way so that the random encounters on a map are only active after a switch is ON? Or more generally any script or plugin that would achieve that?

I also have Visustella.
You can alias Game_Player.prototype.canEncounter or Game_System.prototype.isEncounterEnabled. Doesn't matter which one you pick.

Create a plugin and insert this:

Code:
(function() {
  const alias = Game_Player.prototype.canEncounter
  Game_Player.prototype.canEncounter = function() {
    return $gameSwitches.value(42) && alias.call(this);
})()

Replace 42 with your Switch Id.
$gameSystem.disableEncounter();
$gameSystem.enableEncounter();
$gameSystem.disableEncounter();
$gameSystem.enableEncounter();
Okay that's far easier than my approach 😀
$gameSystem.disableEncounter();
$gameSystem.enableEncounter();

Damn I forgot it's actually a native function lol thanks! 🙂
and it doesn't even need a script, it is an event command as well
Don't we get way too used to relying on plugins? lol
Although truth be told sometimes the native functions are surprisingly limited. But not this time!

Original thread: https://forums.rpgmakerweb.com/threads/random-encounters-only-active-after-a-switch-is-on.151642/