Get player from server function

Hello there is something I still can’t understand with replication system. There is literally no way to get player/player controller/any reference in server functions (client to server communication). In past I developed in roblox for 3 years and I can say even that lego game had pretty “safe” server client system at least you can get real player who sent a message to server (“Player” is automatically referenced in first argument of server function).

In unreal engine you only have one choice which is referencing yourself when calling server functions but this is very bad method since cheaters can reference another player and abuse this a lot you should never trust an information coming from clients.
Is there any other methods to get exact player that I don’t know?
Also another thing I can’t find out how to create a “game” actor and make all clients be able communicate it instead of creating server functions in character. (Only owners can communicate characters)

The message system here has the same, once you figure it out.



ClientReceive(APlayerController* PC, int32 Switch, APlayerState* RelatedPRI_1, APlayerState* RelatedPRI_2, UObject* OptionalObject)


That is what the validate function is for, set something up so that can not happen.

depends on what file your in and what is available in that file.

Clients can not talk to the game mode directly. You however can talk to the game state then it can talk to the game mode.

I’m not sure what do you mean by getting the exact player? The player who called the function on the server? If so, you don’t have to reference anything. I’ll try to explain this as simple as I can. Let’s say that a client player wants to equip a sword:

  • Client: Hey server, I want to equip this sword in my inventory. (ServerEquipSword)
  • Server: Alright, let me check if you have the sword in your inventory in the first place. (ServerEquipSword_Validate)
  • Server: I see the sword in your inventory, I’m equipping it for you. (ServerEquipSword_Implementation)
  • Server: Hey client, I equipped the sword for you. (ClientSwordEquipped rpc sent)
  • Client: Thanks! (ClientSwordEquipped rpc received)

The transition between client/server is done via RPC calls. I think you are familiar with this already. Here is the important part. You don’t have to reference a player, because the server has a copy of the clients as well. When you call ServerEquipSword() on your player, the server will see that this player (in the server’s view: the player who called the RPC on himself basically) wants to equip a sword. So you literally stay in the same class. You don’t have to access which player equipped the sword, because your own copy equips the sword on the server.

Hopefully this makes sense lol
Also, if you want an actor that everyone can communicate with, check out the GameState class.

I meant getting player from unowned actor’s server functions. But I realized unreal engine is lacking this feature since you can’t communicate with unowned actors and there is no way to make your own replication system.

I know how does this work already. My question was about creating unowned actors and handling server functions on it

Can everyone fire game state functions? If so how can you know which player controller fired the server function?
Btw while even searching that I found out someone was in same problem trying to get player and he said he solved it by referencing self in client it’s very exploitable :smiley:

Why don’t you use character? = Imagine you are making a plugin. It would be better to do all replication in one class instead of telling people to setup it manually in their characters. And to be honest it makes the game very messy and unorganized.

Example use cases would be: Door. Yes a simple door coded both client and server side in a single class don’t requiring a third party initialization. You could manage inputs in door’s client side and send message to door’s server when button is pressed. Server receives the request, checks which player sent the request, checks distance etc then replicates the door on every client. This should all happen in single class. But in fact if you want to do this you need to bind input in player character and send request to door.

I wondered and checked this just now.
ClientReceive is server to client function. Something like a game startup. It’s useless to get player controller in client though.
And I see there is no ServerReceive.

Yes, if you set the code to call one of its functions.

Show me your code calling the function into the GameState and from what file. I will show you how to get what ever thing your after whether it is controller or character

To get you on the right track, it is not Self. You will need to use This. Self is used in UDK, This is used in unreal4 engine.

In your last post it seems your really wanting to get the character? You do not want to get it on the client side that is a waste of time. If you are after a character then show me what you a really trying to do and i will show you how to get your character. It is so easy to get a character or a controller at anytime.