Here is a working ct (change teams) command from a plugin I wrote.
From the chat type !ct to change every player humans and bots team.
un-comment this line if you also want the round to immediately end and a new round start.
//ServerCommand("mp_restartgame 1");
Nice effort. You almost had it!
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#pragma semicolon 1
public void OnPluginStart()
{
RegConsoleCmd("sm_ct", Command_SwitchTeams);
}
public Action Command_SwitchTeams(int client, int args)
{
if (GetClientTeam(client) == CS_TEAM_NONE)
return Plugin_Continue;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i))
{
if (GetClientTeam(i) == CS_TEAM_T)
ChangeClientTeam(i,CS_TEAM_CT);
else if (GetClientTeam(i) == CS_TEAM_CT)
ChangeClientTeam(i,CS_TEAM_T);
}
}
//ServerCommand("mp_restartgame 1");
return Plugin_Continue;
}