Freeze enemies when Dialog is open

The way i have enemies show up in my maps is to have them running around, and when they touch you it starts a battle.
Is there a way to tell the program to stop the enemies from moving when the player interacts with somthing?
normally it will freeze enemies when the dialog is open, another way to prevent it
is to make it an autorun and a self switch to the next page or erase event.
I have a good solution for this, since it's also what I use in my game.

Get Yanfly's Stop All Movement script. What it does is allow you to set a switch that stops NPCs from moving, so apply that switch before every dialog you don't want enemies to move in and remove it once the dialog is over.
By default, no. You need a script.

I've moved this thread to RGSSx Script Requests. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/freeze-enemies-when-dialog-is-open.116982/