Download

FString and RPC Compile Error

Any reason why I always get errors trying FString (or TArray or a number of other types) with an RPC. I’ve tried first in playerstate then in playercontroller then in a spawned actor:

in .h



public:  
UFUNCTION(NetMulticast, Reliable, WithValidation) void playerJoined(FString playerNamesSent);


in .cpp



void AReplicationActor::playerJoined_Implementation(FString playerNamesSent) {

}

bool AReplicationActor::playerJoined_Validate(FString playerNamesSent) {
    return true;
    //
}


error:


Severity    Code    Description    Project    File    Line    Suppression State
Error    MSB3075    The command ""C:\Program Files\Epic Games\UE_4.18\Engine\Build\BatchFiles\Build.bat" AudioPartyEditor Win64 Development "C:\Users\Shawn\Documents\Unreal Projects\AudioParty\AudioParty.uproject" -waitmutex" exited with code 5. Please verify that you have sufficient rights to run this command.    AudioParty    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets    41    



If I try int32 or FName it will compile but many other variable types have this error.

Close the error list window, and look at the actual output.
It will tell you: “LogCompile: Error: Replicated FString parameters must be passed by const reference”

So you need to change it to:


UFUNCTION(NetMulticast, Reliable,WithValidation)
void PlayerJoined(const FString& PlayerNamesSent);

Oh man thanks! This has been driving me crazy for days.