How to declare networked functions in 4.22?

I didnt add my whole code here, because everything compiled well, until i add these lines. So… How can i declare server and client functions in 4.22? Everything I can google is sooo old now… :smiley:

In my .h

// - Networked Events
UFUNCTION(Server, Reliable, WithValidation)
void SetMovementInputEventServer(FVector NE_MovementInput);

In my .cpp

// - Networked Events
void AHOPCharacter::SetMovementInputEventServer(FVector NE_MovementInput)
{
	MovementInput = NE_MovementInput;
}

Result:

your .h is fine, but in c++ you need to have it like that :

bool AHOPCharacter::SetMovementInputEventServer_Validate(FVector NE_MovementInput) { return true; }

 void AHOPCharacter::SetMovementInputEventServer_Implementation(FVector NE_MovementInput)
 {
     MovementInput = NE_MovementInput;
 }

the validate function is where you should do the check for anti cheat like behaviours

Wiki is still up to date, the only change is that “WithValidate” is now mandatory for server functions :

Thank you for the answer!! :slight_smile: I already tried it, but it just underlines the function name and says, the class member doesnt have function like this… But now i copy pasted what you gave me(the same i did before) and now it doesnt complains and compiles well. Bur when i make another function exactly like you did it again underlines it… and doesnt compile

i deleted the NE_MovementInput from the validate function

your

void AHOPCharacter::SetMovementInputEventServer_Implementation()

has no parameter should be

void AHOPCharacter::SetMovementInputEventServer_Implementation(FVector NE_MovementInput)

on a side note you can add code easily into AnswerHub

so in the end, did you succed ? note that intellisense has some hard time with UE code gen, so you should try to build even if it’s underlined in red, and output log give you way better information on the actual error ( if there is any )

So in the end, it still underlines the new declarations, but it compiles succesfully. When i reload the whole project, then it doesnt underline it. :slight_smile: Weird