https://forums.totalwar.org/vb/showthread.php?t=64876

But just switching factions just requires the 'control' console command through a script. Have a look in the Scriptorium's Tutorial database in the scripting category for some tutorials on how to put scripts together.