This error is caused whenever you try to get in the Battle Tower, Palace, etc. with an illegal Pokemon (Legendary, Eggs, repeated or holding two of the same item).
The reason why I never got this error is because when I added the Battle places I was still using an script that works correctly with this, but the same script used to make the game crash for Windows XP and older users. Thats why I decided to change it for another script that would work with any OS, but I didn't know that it would mess up with the Battle places.
Now that I know the cause of the problem, the only thing that I have to do is extract the part of the script that works with any OS and change it to the one that used to make the game crash. This will take some time as it looks like the part of the script that works is scattered all over the script.
Meanwhile, if you still want to use the Battle places, make sure you have the correct Pokemon to get in, otherwise the game will crash, and to prevent loss of content, make sure you save before using any of the places.
Thanks for your time, and patience.