void CHL1MP_Player::ChangeTeam( int iTeamNum )
{
	bool bKill = false;

	if ( g_pGameRules->IsTeamplay() == true )
	{
		if ( iTeamNum != GetTeamNumber() && GetTeamNumber() != TEAM_UNASSIGNED )
		{
			bKill = true;
		}
	}

	BaseClass::ChangeTeam( iTeamNum );

	m_flNextTeamChangeTime = gpGlobals->curtime + 5;

	if ( g_pGameRules->IsTeamplay() == true )
	{
		SetPlayerTeamModel();
	}
	else
	{
		SetPlayerModel();
	}

	if ( bKill == true )
	{
		CommitSuicide();
	}
}
void CHL2MP_Player::ChangeTeam( int iTeam )
{
/*	if ( GetNextTeamChangeTime() >= gpGlobals->curtime )
	{
		char szReturnString[128];
		Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch teams again.\n", (int)(GetNextTeamChangeTime() - gpGlobals->curtime) );

		ClientPrint( this, HUD_PRINTTALK, szReturnString );
		return;
	}*/

	bool bKill = false;

	if (iTeam != GetTeamNumber() && GetTeamNumber() != TEAM_UNASSIGNED)
	{
		bKill = true;
	}

	BaseClass::ChangeTeam( iTeam );

	SetPlayerModel();

	if ( iTeam == TEAM_SPECTATOR )
	{
		RemoveAllItems( true );

		State_Transition( STATE_OBSERVER_MODE );
	}

	if ( bKill == true )
	{
		CommitSuicide();
	}
}
void CHL2MP_Player::ChangeTeam( int iTeam )
{
    /*	if ( GetNextTeamChangeTime() >= gpGlobals->curtime )
    	{
    		char szReturnString[128];
    		Q_snprintf( szReturnString, sizeof( szReturnString ), "Please wait %d more seconds before trying to switch teams again.\n", (int)(GetNextTeamChangeTime() - gpGlobals->curtime) );

    		ClientPrint( this, HUD_PRINTTALK, szReturnString );
    		return;
    	}*/
#ifndef GE_DLL
    bool bKill = false;

    if ( HL2MPRules()->IsTeamplay() != true && iTeam != TEAM_SPECTATOR )
    {
        //don't let them try to join combine or rebels during deathmatch.
        iTeam = TEAM_UNASSIGNED;
    }

    if ( HL2MPRules()->IsTeamplay() == true )
    {
        if ( iTeam != GetTeamNumber() && GetTeamNumber() != TEAM_UNASSIGNED )
        {
            bKill = true;
        }
    }

    BaseClass::ChangeTeam( iTeam );

    m_flNextTeamChangeTime = gpGlobals->curtime + TEAM_CHANGE_INTERVAL;

    if ( HL2MPRules()->IsTeamplay() == true )
    {
        SetPlayerTeamModel();
    }
    else
    {
        SetPlayerModel();
    }

    if ( iTeam == TEAM_SPECTATOR )
    {
        RemoveAllItems( true );

        State_Transition( STATE_OBSERVER_MODE );
    }

    if ( bKill == true )
    {
        CommitSuicide();
    }
#else
    BaseClass::ChangeTeam( iTeam );
#endif
}
示例#4
0
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
	}
}
示例#5
0
Worker::~Worker()
{
	CommitSuicide();

	if (NULL != assignmentControl)
		delete assignmentControl;

	if (NULL != thread)
		delete thread;

	if (NULL != csIdle)
		delete csIdle;

	if (NULL != csSuicide)
		delete csSuicide;
}
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
}
示例#7
0
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;
}