I have a bit of a weird “Bug” , First of all i’m using this code
CPP
Header
Ok so when i use this code it all works fine on the client but using the dedicated server in the editor it doesn’t replicate from client 1 to client 2 and when i packaged the project and played the standalone version it only replicated to the server and not other clients. Have i missed something out?
Here, try this. Just be sure to edit it to work for you.
// .h file
UFUNCTION(reliable, Server, WithValidation) // Called on the client executed on the server
void ClientRPCCFunction(const FString & S_String);
UFUNCTION(reliable, NetMulticast) // Called on the server executed to all the clients
void ClientFunc(const FString & C_String);
UPROPERTY(Replicated)
FString test;
// .cpp file
void <YourClass>::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
// Replicate to everyone
DOREPLIFETIME(<YourClass>, test);
}
bool <YourClass>::ClientRPCCFunction_Validate(const FString & S_String)
{
return true;
}
void <YourClass>::ClientRPCCFunction_Implementation(const FString & S_String)
{
TextRender->SetText(FString(S_String));
ClientFunc(S_String); // Updates the Client
}
void <YourClass>::ClientFunc_Implementation(const FString & C_String) // Called on the Server sent to all Clients
{
test = FString(C_String);
TextRender->SetText(FString(test));
}
void <YourClass>::Jump()
{
ACharacter::Jump();
ClientRPCCFunction("HereIsTheName"); // Called on Client Sent to Server
}
Thank you so much, that worked perfect!