no needs to check if is_user_connected. if you are using get_players procedure.
also error: you don't need to use "i" as argument for function, you should use players[i] argument for function.
as for team, you should set team to user before spawn
PHP Code:
new team=random_num(1,2);
cs_set_user_team(players[i], (team==1)?CS_TEAM_T:CS_TEAM_CT)
__________________