Thank you both for your answers! Bugsy's code was very enlightening.
There was also some good info on programming habits that Arukari linked that I will be reading later.
One thing: I probably should have been more specific, but the following code will not increase "count[team]" if the player is already part of the randomly chosen team. This should not be the case, it should increase regardless. But I can fix that myself.
Quote:
Originally Posted by +ARUKARI-
PHP Code:
new const teams[] = {CS_TEAM_CT, CS_TEAM_T};
new count[2];
new id;
for (i = 0; i < numberOfPlayers; i++)
{
id = players[i];
team = random_num(0, 1)
if (cs_get_user_team(id) != teams[team])
{
if (count[team] < maxPlayersPerTeam)
{
cs_set_user_team(id, teams[team])
count[team]++
}
}
}
|
Again, thanks for the speedy replies!
Thread marked as solved.