RealDocs

APlayerState::SetPlayerNameInternal

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

Description

Sets the player name directly without triggering network replication callbacks or broadcasting a name-change message. Used internally when restoring a saved name or initializing the state.

Caveats & Gotchas

  • Unlike SetPlayerName, this does not trigger OnRep_PlayerName on clients and does not send a welcome message. If you call this on the server, clients will only receive the new name when replication catches up — there is no forced push.
  • This is the method called by OnRep_PlayerName on clients to apply the replicated value locally, so overriding it affects both server-initiated changes and client-side replication delivery.

Signature

ENGINE_API virtual void SetPlayerNameInternal(const FString& S);

Parameters

Name Type Description Default
S const FString& The new player name to store locally.

Return Type

void

Example

Restore name from save without broadcasting C++
void AMyPlayerState::InitializeFromSave(const FMySaveData& SaveData)
{
    // Use internal setter to avoid triggering a name-change announcement
    SetPlayerNameInternal(SaveData.PlayerName);
    SetScore(SaveData.Score);
}

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.