We had this problem on our tf2 server , fixed it a very very simple way of client connects to the server it picks a random team and class for them. Simple but effective for our server.
Code:
/* Forceteam code */
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "0.7"
public Plugin:myinfo =
{
name = "CI forceteam",
author = "SMM forums_mega_MrG",
description = "Force player into a team as soon as they connect.",
version = PLUGIN_VERSION,
url = "http://www.cleveridiot.com"
}
public OnPluginStart()
{
CreateConVar ("sm_ci_forceteam_version", PLUGIN_VERSION, "CI forceteam Version", FCVAR_PLUGIN | FCVAR_SPONLY | FCVAR_REPLICATED | FCVAR_NOTIFY);
}
public OnClientPutInServer(client)
{
new iBluTeam = GetTeamClientCount(2);
new iRedTeam = GetTeamClientCount(3);
if(iBluTeam > iRedTeam)
{
ChangeClientTeam(client, 3);
FakeClientCommand(client, "joinclass %s", "random");
}
else if (iRedTeam > iBluTeam)
{
ChangeClientTeam(client, 2);
FakeClientCommand(client, "joinclass %s", "random");
}
else if (iBluTeam == iRedTeam)
{
ChangeClientTeam(client, GetRandomInt(2, 3));
FakeClientCommand(client, "joinclass %s", "random");
}