Set Player Name When Joining a Server (UE 4.2)

I’ve been mucking about with Shooter Game recently trying to get players to be able to join a server and have their names set for them. In the Engine.ini’s I’ve found the name parameter under the URL section but it doesn’t seem to do anything. Using SetPlayerName in the console works for a given round but is reset on map change or round end.

If I print out the options string (if I understand correctly this is where the player’s name would go when they join a server) it just contains the computer’s name which ends up setting the name to the default (computer name followed by what I think is the unique ID of the player).

Any help with this would be greatly appreciated.

Cheers and thanks.

Update:

What I ended up doing was adding a variable, PlayerName, to UShooterLocalPlayer and overriding GetNickName. The variable is populated by Engine.ini.



//ShooterLocalPlayer.h

UCLASS(Config=Engine, transient)
class UShooterLocalPlayer : public ULocalPlayer
{
	GENERATED_UCLASS_BODY()

		UPROPERTY(Config)
		FString PlayerName;

public:

//...
	
 	/**
 	* Returns the name defined in  Engine.ini
	*/
	virtual FString GetNickname() const OVERRIDE;
//...
};




//ShooterLocalPlayer.cpp

FString UShooterLocalPlayer::GetNickname() const {
	
		return this->PlayerName;
}




;Engine.ini

[/Script/ShooterGame.ShooterLocalPlayer]
PlayerName=ThisIsATestName


This seems to work fairly well.

1 Like

Old thread but still useful, thanks!

1 Like