arr, that's a tricky one matey. No, you can't change sides mid-game with one simple command, but it is possible to "fake" it. You gotta explain the situation a little better first tho, although I suppose setcaptive modes or addratings might have to be used
right, setcaptive you know what does, right? If you setcaptivate yourself no-one will attack you though, but on the other hand all you need it that setcaptive FALSE to make the desired party attack you. This might not work so well if you're actually supposed to fight against someone inbetween
the other solution I can come to think of presently would be to use the addRating command (unit addRating ####), basically when your "rating" drops beneath a certain number (specified in the comref, I think), your allies will start attacking you - this is what happens when you kill your pals. So doing a addrating -10000 might do the trick, but be prepared for annoying "3 - cease fire!" and hearing the radio communications of your side :-\ also this method won't exactly stop your previous enemies from attacking you, so...
arr, sorry, but that's all I can come to think of, except actually starting a whole new mission (as in a campaign) at the critical moment
my suggestion is that you just try to fake it somehow using setCaptives or suchlikes...or maybe change the plot
again, sorry but...it's rather hard to do. Maybe Resistance can do it, what do I know
good luck anyhow!
Wolfrug out.