Send arrays from client to server game state

I’m making a 2 player game where each player needs to be able to set and get 3 arrays.
1: CurrentPlayZoneCardIdPool (String Array)
2: CurrnetChargePool (Int aray)
3: CurrnetReversedPool (Boolarray)

One player is a human who used cards to make the move set for the monster. The other player is a monster who battles using said move set.

The way I set it up is each character has local arrays and then will send them to the game state to store the arrays for everyone. So far when the any of the players get the arrays from the game state it is working just fine (good). Or when the player who is the server is setting the arrays on the game state everything is working (also good). Where I’m running into problems is when the client needs to set the arrays, I just can’t seem to get the server game state to get the client arrays (bad).

Blueprint

Game when human is server and it is sending arrays via above blueprint:

Game when human is client and it is sending arrays via above blueprint:

for data sanity you might want to consider CurrentPlayZoneCardidPool to being an int array, or if you can manage with a max potential range of [0-255] a byte (uint8) as you would need to parse an array of strings to id values, and that can bog things down. if you are intent on keeping the Id as “strings” then you might be able to just change it to be a single string that can be parsed into an array upon receipt.

did you give the client authority to modify the given variable. select the array in the Variables section, and then in the Details window check the replication segment.

another way is to have the client instead of sending the full array, have them call a function on the server with the change like playerPlaysCard(int cardID) then the server would validate that the card was in the CardPool, and then perform the action of playing that card if that makes sense.

Here is the string array on the game state

and the one on the player

You’re sending an RPC to the server to multicast, Which is setting values from what it has locally.

Clients need to pass their data via RPC to the server. It then uses those passed values to “Set” vars that are replicated.

So I’m trying to send an array to the game state via RPC and the blueprint is running fine but it looks like the strings from the array are not going from the client to the server.

Player BP:

Gamestate BP:

Gameplay:

To any future people who are having the same problem as me, here is how to fix this.

You first need to send the arrays to the server on the same blueprint making it server side. Then you can cast it to the game state also server side. Finally set the arrays on the game state.

Client blueprint:
image

Game state blueprint:

image

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.