PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
public void OnPluginStart()
{
HookEvent("round_prestart", round_prestart);
}
public Action round_prestart(Handle event, const char[] name, bool dontbroadcast)
{
ServerCommand("mp_autoteambalance 0");
int ctone = GetRandomPlayer();
if (ctone)
{
CS_SwitchTeam(ctone, CS_TEAM_CT);
}
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && i != ctone)
{
CS_SwitchTeam(i, CS_TEAM_T);
}
}
}
GetRandomPlayer()
{
int clients[MAXPLAYERS + 1], clientCount;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == CS_TEAM_T)
{
clients[clientCount++] = i;
}
}
return clientCount ? clients[GetRandomInt(0, clientCount - 1)] : 0;
}