Custom Party Player Variables
Sooner or later you will probably want to add custom variables to party players instead of using the built-in Player Data feature. This guide will walk you through the process of creating custom replicated variables inside the party player state.
Setting Up Custom Player Variables
1. Creating the Party Player State class
First, create a new blueprint from the KronosPartyPlayerState class.

Now go to Project Settings -> Kronos Matchmaking and change the "Party Player State Class" to your custom blueprints.
2. Setting up Custom Variables
I'm going to create a new string variable simply called MyCustomString. Make sure that the variable's Replication is set to RepNotify! This will automatically create an OnRep function for us as well.
I'm also going to create a new event dispatcher for when the variable is changed. Since my variable is a string, I'm going to add a string param to the event dispatcher so that it can broadcast the new value.

3. Implementing the OnRep Function
Next we need to implement the OnRep function of the variable. This is called automatically by Unreal when the value of the replicated variable is changed. Here I simply want to call the event dispatcher created earlier.

Each party client now has MyCustomString replicated in their player states.
Modifying Custom Player Variables
Now that each party client has MyCustomString replicated in their player states, we just need a way to change the value of this variable. For this we are going to use the KronosPartyClient class, and I quickly want to explain why.
The KronosPartyPlayerState can replicate variables but it does not have RPC capabilities!
This is due to it being stored in a FastArraySerializer inside the KronosPartyState.
This means that the KronosPartyPlayerState should be used for data storage only, while the transition process from client to server should be done in the KronosPartyClient class instead.
1. Creating the Party Client class
First, create a new blueprint from the KronosPartyClient class.

Now go to Project Settings -> Kronos Matchmaking and change the "Party Client Class" to your custom blueprints.
2. Creating the Set Value Function
Create a new custom event called SetMyCustomString. Make sure that this event is set to "Run On Server" and Reliable! This will be the function to call when we want to change the value of the variable.

Now to actually change the value of MyCustomString, we simply need to get the player state of the party client, cast it to our custom blueprint, and set the string's value. Since the value is replicated it will now replicate down to the client and all other party members.

Calling SetMyCustomValue will now change the variable value of the party client.
Reading Custom Player Variables
In order to get the value of MyCustomString all we need to do is get a reference to the KronosPartyPlayerState, cast it to our custom blueprint, and get the current value. How we get the reference highly depends on the context. Here are some examples:
From party client: Use
GetPlayerStatefunction.From party player actor: Use
GetOwningPartyPlayerStatefunction.From party player widget: Use
GetOwningPartyPlayerStatefunction.
Initializing Custom Player Variables
Use the built-in ServerInitPlayer and ClientInitPlayer functions of the KronosPartyClient. Please refer to Initializing Party Players section of the documentation for more details.
Last updated