The Control Variables command DOES give you the ID of the current map. It didn't work for you because after you ran that command, you ran another one overwriting what was in the variable with something else.
You don't need to use a script when you have an event command that does exactly what you want.
You don't need to use a script when you have an event command that does exactly what you want.