Parameters from client to server events

Hello :slight_smile:

I started working with UE recently and now I’m diving into multiplayer systems. So my question: is it safe to pass the parameters from client to server when using “on server” events? Simple example: RTS game, I want to build a building. Of course, server does not know nothing about my cursor. So I’ve to pass the cursor location somehow. But player (read as cheater) can pass there anything he wants.

Or another example: player builds a turret. The turret shot down some target. To track who shot I can pass the reference from the player to turret → from turret to bullet actor (I know that it’s much better to “getOwner” from server event but anyway). But as I mention before: is it “safe”? I mean in theory player can pass a reference to another player?

What are good practices should I use? Should I avoid to pass params into the server events?

I will be very grateful for your answers :slight_smile:

When making a client → server RPC call, only clients that are considered “owning clients” can successfully send RPC’s to the server.

(from this very helpful doc: RPCs | Unreal Engine 4.27 Documentation)

In most games a client’s PlayerController is the one “owned” by them. You can check if a client is owner of a PlayerController using something like this: Is Local Player Controller | Unreal Engine Documentation.

Only clients who are locally controlled can send RPC’s to the server successfully.

As an example, the client who owns Player 1 can send successfully RPC’s about Player 1, but not about Player 2, and vice versa.

1 Like

Basically nothing is safe when it originates from a client but the client still need to convey their intent to the server obviously.

The server needs to do its own sanity checks of the input it gets from the client and reject it if it doesn’t comply with the constraints you make.

Since you just started diving into multiplayer you have many other concerns to focus on first just to ensure things are in sync to begin with.
Fighting cheaters is a battle that is pretty much impossible to win if you don’t use dedicated servers or have a team of developers and testers to help you find holes in your programming.

1 Like