void CSDKPlayer::ChangeTeam( int iTeamNum ) { if ( !GetGlobalTeam( iTeamNum ) ) { Warning( "CSDKPlayer::ChangeTeam( %d ) - invalid team index.\n", iTeamNum ); return; } int iOldTeam = GetTeamNumber(); // if this is our current team, just abort if ( iTeamNum == iOldTeam ) return; m_bTeamChanged = true; // do the team change: BaseClass::ChangeTeam( iTeamNum ); // update client state if ( iTeamNum == TEAM_UNASSIGNED ) { State_Transition( STATE_OBSERVER_MODE ); } else if ( iTeamNum == TEAM_SPECTATOR ) { RemoveAllItems( true ); State_Transition( STATE_OBSERVER_MODE ); } else // active player { if ( !IsDead() ) { // Kill player if switching teams while alive CommitSuicide(); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); } if( iOldTeam == TEAM_SPECTATOR ) SetMoveType( MOVETYPE_NONE ); //Tony; pop up the class menu if we're using classes, otherwise just spawn. #if defined ( SDK_USE_PLAYERCLASSES ) // Put up the class selection menu. State_Transition( STATE_PICKINGCLASS ); #else State_Transition( STATE_ACTIVE ); #endif } }
bool CHL2MP_Player::HandleCommand_JoinTeam( int team ) { #ifndef GE_DLL if ( !GetGlobalTeam( team ) || team == 0 ) { Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team ); return false; } if ( team == TEAM_SPECTATOR ) { // Prevent this is the cvar is set if ( !mp_allowspectators.GetInt() ) { ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" ); return false; } if ( GetTeamNumber() != TEAM_UNASSIGNED && !IsDead() ) { m_fNextSuicideTime = gpGlobals->curtime; // allow the suicide to work CommitSuicide(); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; #else return false; #endif }
bool CHL2MP_Player::HandleCommand_JoinTeam( int team ) { if ( !GetGlobalTeam( team ) || team == 0 ) { Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team ); return false; } if ( team == TEAM_SPECTATOR ) { // Prevent this is the cvar is set if ( !mp_allowspectators.GetInt() ) { ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" ); return false; } if ( /*GetTeamNumber() != TEAM_UNASSIGNED &&*/ !IsDead() ) //DHL - Skillet - Players in deathmatch are unassigned { m_fNextSuicideTime = gpGlobals->curtime; // allow the suicide to work CommitSuicide(); // add 1 to frags to balance out the 1 subtracted for killing yourself IncrementFragCount( 1 ); GetTeam()->AddScore( 1 ); //DHL - Skillet - Required to keep the scoreboard headers from getting out of sync } ChangeTeam( TEAM_SPECTATOR ); return true; } else { StopObserverMode(); State_Transition(STATE_ACTIVE); } // Switch their actual team... ChangeTeam( team ); return true; }