1. Correct, you are only accessing players[] once per pass so it is fine.
2. Yeah, see the below code.
For your last question, it's called
Hungarian notation. It helps the developer and/or person looking at the code what type of data is held in the variable. sz being null-terminated string.
PHP Code:
new iPlayer , CsTeams:csCurrentTeam , csTeamCount[ CsTeams ];
for ( i = 0 ; i < numberOfPlayers ; i++ )
{
iPlayer = players[ i ];
csCurrentTeam = cs_get_user_team( iPlayer );
switch ( CsTeams:random_num( _:CS_TEAM_T , _:CS_TEAM_CT ) )
{
case CS_TEAM_T:
{
if ( csTeamCount[ CS_TEAM_T ] < maxPlayersPerTeam )
{
if ( csCurrentTeam != CS_TEAM_T )
{
cs_set_user_team( iPlayer , CS_TEAM_T)
}
csTeamCount[ CS_TEAM_T ]++
}
else
{
cs_set_user_team( iPlayer , CS_TEAM_CT)
csTeamCount[ CS_TEAM_CT ]++
}
}
case CS_TEAM_CT:
{
if ( csTeamCount[ CS_TEAM_CT ] < maxPlayersPerTeam )
{
if ( csCurrentTeam != CS_TEAM_CT )
{
cs_set_user_team( iPlayer , CS_TEAM_CT)
}
csTeamCount[ CS_TEAM_CT ]++
}
else
{
cs_set_user_team( iPlayer , CS_TEAM_T)
csTeamCount[ CS_TEAM_T ]++
}
}
}
}
__________________