Couple other problems/bugs ...
If the player (in say a M4) gets the message that the invasion is coming, and imeadiatly jumps to the sector only the 1st ship (the invading.race M2) will arive and go on a rampage killing all 'enemy', no other ships jump in, the script will never complete and the M2 will stay there.
Ive double checked this, if I stay OOS and just watch all ships will jump in and the script runs its course, but if I jump in before all ships arrive something gets messed up. (some part of your script is checking to see if 'player' is in sector and changes a value based on that right?)
After an OOS battle completes and a sector changes hands all combat ships (m5-m2 that Ive noticed) that werent actualy part of the invasion become zombies and just sit there. ie sector patrols and any fighters that happened to be in the sector. For some reason they stay that way until the player arrives in sector again then they all start moving ... some issue with the game not liking sectors changing ownership?
I also modified your script to bring the forces in by random sector gates rather than all appear in the middle ... makes for a more interesting and varied fight
M