Variables to select maps?

So I have a few different maps created and I was wondering if it is possible to use a random number generator to select up to 5 of them and change the entrances and exits with variables so they lead to each other,

say I have:
Map 1
Map 2
Map 3 etc.
and the rng chose map 5, 7, 9 and 10 would it be possible to change the entrances and exits of them all so they lead to each other?

p.s.
I don't mind scripts or plugins

Also as you can transfer player by using variable id can you use that to take you to a random map?
of course - and transfer player command is the way to go, no need for a plugin.

if the transfer player command uses the variable option, then the number in the variable to be used for map is the ID of that map - the number you see in the bottom left.

However, because that number needs to be the map ID, you need to use control variable in a way to get the correct numbers.
The easiest way is if the target maps are a sequence of numbers - for example if you want to end up on a map between map ID 8 and 12, then you use a single control variable to get a random number in that range and then use the transfer command.

If the map numbers are not a sequence, you need a series of conditional branches to convert a random number into the map ID.
In your example above, that would be first a control variable random 1-4 (because you have four maps), then four conditional branches "if variable = 1 then set variable to 5, if 2 then set to 7 and so on - followed by the transfer command.
thank you

Original thread: https://forums.rpgmakerweb.com/threads/variables-to-select-maps.81203/