Hi all, as the title says.. how can I do this?
I have this code, but it does't work (the round ends anyway):
PHP Code:
public client_disconnect(id) if(is_user_alive(id)) check_round(); // call check round function
check_round(){
if(g_bRoundEnd) return; // round ending bool (false on round start, true on round end)
static szName[32], randomplayer; randomplayer = fnGetRandomPlayer();
if(fnGetTeamPlayers(1) == 1){
cs_set_user_team(randomplayer, CS_TEAM_T); // change team
get_user_name(randomplayer, szName, 31 ); // get the name
client_print(0,print_chat,"The last TT left, %s is the new TT",szName); // advertise which player
ExecuteHamB(Ham_CS_RoundRespawn, randomplayer); // respawn the new last player
}
}
fnGetTeamPlayers(team) {
static i, iPls;
for (i = 0; i < g_iMaxpl; i++){
if (is_user_connected(i)){
switch(team){
case 1:if (cs_get_user_team(i) == CS_TEAM_T) iPls++;
case 2:if (cs_get_user_team(i) == CS_TEAM_CT) iPls++;
}
}
}
return iPls;
}
fnGetRandomPlayer(){
new iPlayers[32], iNum
get_players(iPlayers, iNum, "h")
if( iNum <= 1 ) return iPlayers[0]
new iRandomNum = random(iNum)
new iRandomPlayer = iPlayers[ iRandomNum ]
if( iRandomPlayer == g_iLastChoosenPlayer ){
iPlayers[ iRandomNum ] = iPlayers[ --iNum ]
iRandomPlayer = iPlayers[ random(iNum) ]
}
g_iLastChoosenPlayer = iRandomPlayer
return iRandomPlayer
}