Priority between OnConnectedToServer and OnPlayerConnected

Hello !

I want to make some kind of chat.
I have a problem concerning the connection of a new player to my server. At the connection, the new player has to send its nickname to the server, and then the server has to display it for every client and himself of course.

So I created my functions OnConnectedToServer, which send the nickname to the server via RPC function, and OnPlayerConnected which send all the nicknames to the clients.

I made it like that to centralize all the datas in the server, to avoid one client to not “see” an other client previously connected.

My problem is the OnConnectedToServer is called AFTER OnPlayerConnected. How can I fix this, or at least bypass this problem easily ?

Thanks !

OnPlayerConnected fires first because the server will be the first to know the connection has been established successfully. Instead of relaying the nickname in OnPlayerConnected you could relay them when picking up the RPC on the server. When the nickname is received, send it to the other clients.