Send var from client to server at connection time before spawning

I tried sending options with the connection URL in this two ways :

  • open 192.168.1.8?zvalue=xxx
  • using the “Open Level” node putting zvalue=xxx in the options, with Absolute both checked and unchecked.

In the game mode on the server at spawn time, when I get the “options string” and print it, I can only find the options with which the server launched the current level, namely “?listen” . no trace of the client ones.

What am I doing wrong?

Please note that I read a lot about how to make RPC call to send info from client to servers, but what I need is to send those info before spawning. I cannot do the workaround to spawn into a fake spectator pawn , do the thing and then change pawn.

Thanks.

I am not sure what kind variables do you want to send to the Game Mode but can’t you put the values in a APlayerState object?

I just thought about that! will it work? setting the variable (a mere float) in the player state, connect to the server and at PostLogin time, retrieve it from the “New Player” pin ? As soon as I finish implementing it I will know for sure, but in the meanwhile I ask XD

Well the Player State is replicated and presist between sesions. It is frequently used for storing and transfering player name, chosen character and team from the main menu Game Mode to the multiplayer match. I think it will work.

Now that I think of it… Is there a reason for the value not to be part of the Player controller?

You should check these tutorials as I am a bit rusty on the subject: Blueprint Multiplayer: Project Overview | 01 | v4.11 Tutorial Series | Unreal Engine - YouTube

I’ll check the tutorial as soon as possible ! In the meanwhile I tried saving the variable in the player state before connecting to the server , and then in the multiplayer game mode , on post login method I dragged from the new player pin, but the value is 0. Not the o e I previously set . Why ???

I never got my player states to persist between levels.
I had to save and load on client side then after joining send client preferences to the server and have the server set the player state values to what the client sent in.