void APlayerState::OnRep_PlayerName()
{
	OldName = PlayerName;

	if ( GetWorld()->TimeSeconds < 2 )
	{
		bHasBeenWelcomed = true;
		return;
	}

	// new player or name change
	if ( bHasBeenWelcomed )
	{
		if( ShouldBroadCastWelcomeMessage() )
		{
			for( FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator )
			{
				APlayerController* PlayerController = *Iterator;
				if( PlayerController )
				{
					PlayerController->ClientReceiveLocalizedMessage( EngineMessageClass, 2, this );
				}
			}
		}
	}
	else
	{
		int32 WelcomeMessageNum = bOnlySpectator ? 16 : 1;
		bHasBeenWelcomed = true;

		if( ShouldBroadCastWelcomeMessage() )
		{
			for( FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator )
			{
				APlayerController* PlayerController = *Iterator;
				if( PlayerController )
				{
					PlayerController->ClientReceiveLocalizedMessage( EngineMessageClass, WelcomeMessageNum, this );
				}
			}
		}
	}
}
Exemplo n.º 2
0
void APlayerState::Destroyed()
{
	if ( GetWorld()->GameState != NULL )
	{
		GetWorld()->GameState->RemovePlayerState(this);
	}

	if( ShouldBroadCastWelcomeMessage(true) )
	{
		for( FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator )
		{
			APlayerController* PlayerController = *Iterator;
			if( PlayerController )
			{
				PlayerController->ClientReceiveLocalizedMessage( EngineMessageClass, 4, this);
			}
		}
	}

	// Remove the player from the online session
	UnregisterPlayerWithSession();
	Super::Destroyed();
}