How to make this USTRUCT replicatable?

I want to make this USTRUCT replicatable.
How can I replace the

std::vector<std::pair<WARRIOR_TYPES,int32>>

in UE4 to make it replicatable?

TArray<TSet<>> //or// TArray<TMap<>>

WARRIOR_TYPE [key] is an enum and num [values] is an int32.

USTRUCT(BlueprintType)
struct FWarriorUnit{

	GENERATED_USTRUCT_BODY()

	//TArray<TMap<> warriors;
	std::vector<std::pair<WARRIOR_TYPES,int32>> warriors;

	FORCEINLINE int32 getNumWarriorsByType(WARRIOR_TYPES type){
		for (int i = 0; i < this->warriors.size(); i++){
			//assumes that there is only one element in warriors for every WARRIOR_TYPE
			if (warriors[i].first == type) return warriors[i].second;
		}
		return 0;
	}

	FORCEINLINE void addWarrios(WARRIOR_TYPES type, int num){
		for (int i = 0; i < this->warriors.size(); i++){
			if (warriors[i].first == type){
				warriors[i].second += num;
				//assumes that there is only one element in warriors for every WARRIOR_TYPE
				return;
			}
		}
		warriors.push_back(std::pair<WARRIOR_TYPES, int32>(type, num));
	}

	FORCEINLINE void removeWarriors(WARRIOR_TYPES type, int num){
		for (int i = 0; i < this->warriors.size(); i++){
			if (warriors[i].first == type){
				warriors[i].second -= num;
				if (warriors[i].second < 0) warriors[i].second = 0;
				//assumes that there is only one element in warriors for every WARRIOR_TYPE
				return;
			}
		}
	}

};

From what i know, u cannot replicate TMap or TSet, you need to make 1 more USTRUCT to hold the WARRIOR_TYPES and int32 something like:

USTRUCT()
struct FWarrior{
     WARRIOR_TYPES wariorType;
     int32 num;
}

then in your FWarriorUnit make a TArray Warriors. With that FWarriorUnit now can replicate like normal.

just answer yours, so do you already put all the stuff like replicated in UPROPERTY and DOREPLIFETIME for your variable ? and do your enum is UENUM() ?

I bypassed it with

USTRUCT(BlueprintType)
struct FWarriorPair{

	GENERATED_USTRUCT_BODY()

	UPROPERTY()
	int32 num;
	UPROPERTY()
	TEnumAsByte<WARRIOR_TYPES> type;

	FWarriorPair(int32 num, WARRIOR_TYPES type){
		this->num = num;
		this->type = type;
	}
	FWarriorPair(){
		this->num = 0;
		this->type = WARRIOR_TYPES::NONE;
	}

};

and hold FWarriorPair in a TArray.
but the question remains

Yep, thanks for your answer anyway ;D But, somewhere I red that TArray needs some special replication technique. Do I have to worry about something or do I prevent that by using the Array just ‘indirectly’ in the struct?

Uhm, not really, i use TArray replicate a lot on my project seen first UE4 version, no problem so far.

Okay, good. Thanks :slight_smile:
I asked because of this document https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/Implementation/DynamicArrays/index.html