Well, these don't really address the problem you posted, but they're things that will likely get mentioned by a SourceMod approver if you submit it as a new plugin:
1.
PHP Code:
ServerCommand("mp_autoteambalance 0");
ServerCommand("mp_teams_unbalance_limit 0");
I'm not sure its a good idea to set cvars using ServerCommand. Use a handle variable, FindConVar (in OnPluginStart), and SetConVarBool instead.
2.
Hook either OnClientDisconnect or OnClientDisconnect_Post, not both. I recommend OnClientDisconnect_Post based on what you're doing.
3.
PHP Code:
#define TEAM_UNASSIGNED 0
#define TEAM_SPEC 1
#define TEAM_RED 2
#define TEAM_BLUE 3
Use these from #include <tf2> instead:
PHP Code:
TFTeam_Unassigned
TFTeam_Spectator
TFTeam_Red
TFTeam_Blue // (yes, Blue... not Blu)
You can compare them directly without casting, but you may need to cast them to a cell before using them with GetTeamClientCount (i.e. _:TFTeam_Red)
__________________