Download

Get a unique Player ID over a multiplayer network. (Not Local)

So I was wondering if there was a way to give or get a unique ID to/from all the players connected to the server.

I have this: (Concept)
No5Le24.png

From what I understand though, “Player Index” only works with LOCAL multiplayer, and that is not my intention.

So I was wondering if there was a way to get some sort of netID? Or something unique to the player when they connect? Or if I could create one in the construction of a player?

Hi, yes gamemode has a gamestate that has an array of all the players gamestate connected to server. So you need to get the GameMode -> getGameState -> PlayerArray-> PlayerId. I think GameMode only exist on the server so be careful when you try to access it.

Thank you, that’s great. Just what I was looking for really. Is there an event that happens when a new player is added to the PlayerArray? So I could put some of my own logic into it when that happens?

Networking3.PNG

Well I thought I had it, but all clients and the server is returning their playerID as 0. Then I get an error “Error Accessed None ‘PlayerState’ from node New Event Dispatcher 0 in blueprint FirstPersonCharacter” so it’s receiving null for the playerstate?

You could assign a custom player ID whenever a new player joins. Player joins can be detected in the game mode blueprint server-side using a Event Post Login. It would look like this in your game mode blueprint:

a061c7f87d2d393c98ac83415059c5c775da68d0.png

In this case my default controller class is ExampleController and I have given it a replicated int variable PlayerID.

…check my comments here:
https://answers.unrealengine.com/questions/429458/get-player-id-from-character-blueprint.html