RealDocs

APlayerState::GetPlayerId

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

Description

Returns the player's unique numeric ID assigned by the server. This ID is guaranteed to be unique per player within a session but its actual value is opaque and session-local.

Caveats & Gotchas

  • PlayerId is a session-local integer assigned by the server — it is NOT a persistent identity across sessions or a platform account ID; use GetUniqueId for persistent cross-session identification.
  • The value is replicated via OnRep_PlayerId so clients may briefly see a default value of 0 before the first replication arrives.

Signature

int32 GetPlayerId() const

Return Type

int32

Example

Use PlayerId as a scoreboard sort key C++
TArray<APlayerState*> Players = GameState->PlayerArray;
Players.Sort([](const APlayerState& A, const APlayerState& B)
{
    return A.GetPlayerId() < B.GetPlayerId();
});

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.