RealDocs

APlayerState::SetOldPlayerName

function Engine Since 4.0
#include "GameFramework/PlayerState.h"
Access: public Specifiers: virtualENGINE_API

Description

Stores a string as the player's previous name for later retrieval by GetOldPlayerName. Called by the engine just before applying a new player name on the client.

Caveats & Gotchas

  • This is an engine-internal bookkeeping call made inside OnRep_PlayerName on the client. Calling it manually will silently overwrite the saved old name, potentially breaking name-change detection in your UI.
  • OldNamePrivate is not replicated, so SetOldPlayerName on the server has no effect on clients. It is only meaningful in the client-side replication callback path.

Signature

ENGINE_API virtual void SetOldPlayerName(const FString& S);

Parameters

Name Type Description Default
S const FString& The name string to store as the previous player name.

Return Type

void

Example

Custom override to also log the old name C++
void AMyPlayerState::SetOldPlayerName(const FString& S)
{
    UE_LOG(LogGame, Verbose, TEXT("Player old name cached: %s"), *S);
    Super::SetOldPlayerName(S);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.