PHP Code:
public RandomTeams()
{
MatchStart = true
new players[32], pnum, tempid;
get_players(players, pnum, "h");
for( new i; i<pnum; i++ )
{
tempid = players[i];
switch ( cs_get_user_team( tempid ) )
{
case CS_TEAM_T, CS_TEAM_CT:
{
if(is_user_alive( tempid))
user_silentkill(tempid);
rg_set_user_team(tempid, TEAM_SPECTATOR, MODEL_AUTO, true)
}
}
}
new topick, idop
while (AnyoneInSpec())
{
if (cs_get_user_team(players[idop]) == CS_TEAM_UNASSIGNED)
{
idop++
continue;
}
topick = random(2)
if (topick == 1)
{
rg_set_user_team(players[idop], TEAM_TERRORIST, MODEL_AUTO, true)
}
else
{
rg_set_user_team(players[idop], TEAM_CT, MODEL_AUTO, true)
}
new pplayers[32], ppnum, tempid;
new ppplayers[32], pppnum;
new temppnum
get_players(players, pnum, "h");
get_players(pplayers, ppnum, "he", "CT")
get_players(ppplayers, pppnum, "he", "TERRORIST")
if (ppnum == pnum/2)
{
get_players(players, temppnum, "h");
for( new i; i<temppnum; i++ )
{
tempid = players[i];
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
{
rg_set_user_team(tempid, TEAM_TERRORIST, MODEL_AUTO, true)
}
}
}
else if (pppnum == pnum/2)
{
get_players(players, temppnum, "h");
for( new i; i<temppnum; i++ )
{
tempid = players[i];
if (cs_get_user_team(tempid) == CS_TEAM_SPECTATOR)
{
rg_set_user_team(tempid, TEAM_CT, MODEL_AUTO, true)
}
}
}
idop++
}
}