I made something similar for my server. Admins can type the command !balance to balance the teams. It's useful for when players voted for botsvshumans and realize they are in over their head. They can then vote for team balance which launches !balance.
Your code kicks Bots when the player count is uneven. The code below does nothing unless the !balance command is used. It then moves players to different teams in an effort to balance the teams evenly. The code isn't complicated and works well for my needs. Maybe it will help you.
PHP Code:
#include <sourcemod>
#pragma newdecls required
public Plugin myinfo =
{
name = "Balance Team",
author = "PC Gamer",
description = "Place equal number of Players on each team",
version = "PLUGIN_VERSION 1.0",
}
public void OnPluginStart()
{
RegAdminCmd("sm_balance", Command_balteam, ADMFLAG_SLAY, "Balance the Players on Each Team");
}
public Action Command_balteam(int client, int args)
{
int pcount = 1
for(int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && (pcount % 2 == 0))
{
ChangeClientTeam(i, 2); //change player to Red Team
}
if (IsClientInGame(i) && (pcount % 2 == 1))
{
ChangeClientTeam(i, 3); //change player to Blue Team
}
if (IsClientInGame(i))
{
pcount++;
}
}
return Plugin_Handled;
}