Separate server and client execution for listen server host ?

Hello everyone currently I’m working on a multiplayer system in UE5 and running into an issue specifically with listen server behavior.

I have a function that should behave differently depending on where it is executed:

  • If called on server → run server logic (e.g. multicast / replication)

  • If called on client → run client-only logic (visuals, local effects)

This works fine in:

  • Dedicated server + clients

  • Standalone


On a listen server host, both of these are true:

HasAuthority() == true
IsLocallyControlled() == true

Because of that, I cannot distinguish whether the function was triggered as:

  • a server execution, or

  • a client/local execution


What I want

I want a single function that:

  • Runs only server logic if triggered from server

  • Runs only client logic if triggered from client

  • Does NOT run both on listen server host

  • Works consistently across:

    • dedicated server

    • listen server clients

    • clients


What I’ve tried

  • HasAuthority() → always true on listen server

  • IsLocallyControlled() → also true on listen server

  • GetNetMode() → only tells environment, not execution origin

  • Multicast / Client RPC combinations → still don’t solve execution origin ambiguity


Constraint

I’d prefer not to pass extra parameters (like a “bFromServer” flag) into the function if possible.


This(?) :thinking:

NOT IsServer → Client
IsServer && NOT IsDedicatedServer → ListenServer

Is Server is the first preferred flag check. Beyond that you can use Get Local Role (Autonomous, Authority, Simulated).

Depending on what function you want the server to execute you could…

Branch (Is Server ) [true] → Server stuff, [false] get local role == Autonomous → Client stuff, else simulated proxy stuff.