Map encounters only after a switch?

Is it possible to have it where there will only be troop encounters in a map after a switch has been turned on?
Ruby:
class Scene_Map < Scene_Base
  def update_encounter
    return if $game_switches[1] == false
    SceneManager.call(Scene_Battle) if $game_player.encounter
  end
end
change the switch number to your desired switch.
no need for a switch - there is an event command to turn encounters on and off
no need for a switch - there is an event command to turn encounters on and off
And where is this event command? Could you tell me how I could create or find it?
Oh wait.
no need for a switch - there is an event command to turn encounters on and off
Oh wait, I think I found it! Thank you!
no need for a switch - there is an event command to turn encounters on and off
True, forgot about that.

Original thread: https://forums.rpgmakerweb.com/threads/map-encounters-only-after-a-switch.160907/