Differentiating Authority on Listen Server.

The problem is In a replicated function or event like BeginPlay How’ll you know that you are a player who is playing on the same machine that is hosting the listen server and switch/Branch using else if on that ?

Everything in context of listen server

Take the case of Functions and events that are called on both server and clients like Beginplay

for Example case Lets assume we have to send some data to server as a “player” i.e from your Machine or player input.

Now if you use BeginPlay of playerState to send the data you’ll run into following issues.

if you check for Role<Authority then you miss out the player on the server since he’s role Authority on his own machine

if you check for Role == Authority you’ll get the player on the server machine but lose every remote player

if you check NetMode == NM_ListenServer then every player state on the server will have Netmode Listen Server so you’ll actually be calling the functions on server not the client

Oh boy! remote role of the controller?

Look here, in your case you should check Role and RemoteRole.

Wait, I think I’d understand what you want to achieve: you need to run some code on each client(on player’s character) and on listen server client character.
If I’m right you should check:



if (Role == ROLE_AutonomousProxy || (Role == ROLE_Authority && RemoteRole < ROLE_AutonomousProxy))
{
    //
}


But this will work only within PlayerController.

So for this question:

answer would be (Role == ROLE_Authority && RemoteRole < ROLE_AutonomousProxy).

Very confusing case, I edit code few times and still have feeling that something is wrong.)

Hi, on the playercontroller there is a function “bool IsLocalPlayerController()” which does exactly what you want if im not mistaking.