Doing that and turning off the self switch a when losing makes the event repeat without even having the opportunity to go to the pokemon center :'). I'm starting to lose hope
EDIT: Nevermind, I forgot to tell the game I can't lose that battle. Now it seems to work fine, as I come back to the zone and the event doesn't start automatically. This possibly means the problem is with creating trainers with scripts.