Don't know about other people, but I would do like this.
PHP Code:
#include <sourcemod>
#pragma semicolon 1
bool g_bRestrict;
int g_iTeam[MAXPLAYERS + 1];
public void OnPluginStart()
{
HookEvent("round_start", Event_Start);
HookEvent("round_end", Event_End);
HookEvent("player_team", Event_Team);
}
methodmap Restrict
{
public static int Check(int iClient)
{
if (g_bRestrict)
{
if (IsValidClient(iClient))
{
if (g_iTeam[iClient] > 1)
{
if (g_iTeam[iClient] != GetClientTeam(iClient))
{
ChangeClientTeam(iClient, g_iTeam[iClient]);
}
}
}
}
}
}
public Action Event_Start(Event hEvent, const char[] sName, bool bDontBroadcast)
{
g_bRestrict = !g_bRestrict;
for (int i = 1; i <= MaxClients; i++)
Restrict.Check(i);
}
public Action Event_End(Event hEvent, const char[] sName, bool bDontBroadcast)
{
g_bRestrict = !g_bRestrict;
for (int i = 1; i <= MaxClients; i++)
Restrict.Check(i);
}
public Action Event_Team(Event hEvent, const char[] sName, bool bDontBroadcast)
{
int iClient = GetClientOfUserId(hEvent.GetInt("userid"));
if (!g_bRestrict)
g_iTeam[iClient] = GetClientTeam(iClient);
}
stock bool IsValidClient(int iClient)
{
if (!(0 < iClient <= MaxClients) || !IsClientInGame(iClient) || IsFakeClient(iClient))
{
return false;
}
return true;
}