Set Array Elem problem

Hi, I created a dynamic array in C++:


UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Weapon Inventory")
TArray<bool> WeaponInventory;

and I replicated it using the DOREPLIFETIME macro. The problem is that if I try to set an array element from a Blueprint, I can set it only on the client, because on the server it doesn’t work. Why?

I did this on my blueprint:

http://puu.sh/dObHv/8aa64a8806.jpg

Could a good samaritan please help us out with this issue? Thanks!

The only work around I found for this is using the Set Members In node, which allows you to modify a variable by reference. If you simply get the object out of the Array by index, then Set Members In. This will expose the variable of the Array Element, allowing you to update it.

Thanks for the reply, but I can find only these nodes:

http://puu.sh/e12wV/6abcc815a1.png

What I have to do now?

Make it a Structure instead of using Bools, its an extra conversion. But that will allow you to use Set Members In.

I did what you said, but there is the same problem: the variable changes on the client, but not on the server. Here there is the blueprint:

http://puu.sh/e1COR/d32155e162.jpg

Oh I’ve overlooked the initial problem, my apologies! The variable is set to replicate? (Looks to be)

Thanks for the reply. How can I set an UPROPERTY Reliable? I knew that it was possible only for UFUNCTIONS.

That’s what I meant, setting it to Replicate but I seen you’re already doing it.

Edit

Try RepNotify instead!

The array or the struct is replicated, but the replication doesn’t work. Is this a bug?

Have you already tried RepNotify?

Also, if you wanted to notice the changes immediately. It would be better to use a replicated reliable function.

I did this:

But when I go on the pickup, this is the variable value:

http://puu.sh/e28KL/40b4bcd4fc.jpg

Can anyone help us? Thanks.

We probably need a developer to help us out with this. It seems kind of complex for the average user.
This is very important for us to keep up the workflow and get the inventory system working properly.

Hey, im having the same issue and could use help too. Thx

Items to be replicated should be behind a “has authority” node. In other words, on the server side only. Vars changed on the client wont replicate to another client. The Content Examples has a good explanation of this

If you see the first screenshot, there is already the “Has authority” node.

Hey, i found what was my issue, maybe it is the same as you : “Clients should not add or remove elements on replicated arrays.” https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/Implementation/DynamicArrays/index.html

Yes, but the element is set by the server (Switch Has Authority).