RPCs error

I was trying to make RPCs functions, but i got some errors.

This is my code

private:
UPROPERTY(Replicated)
FString PCInfo;


UFUNCTION(NetMulticast, Reliable, WithValidation)
virtual void TakeHardware();
UFUNCTION(Server, Reliable, WithValidation)
virtual void SendHardware();

void GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const;
#include "PuzzlePlatformsCharacter.h"
#include "HeadMountedDisplayFunctionLibrary.h"
#include "Camera/CameraComponent.h"
#include "Components/CapsuleComponent.h"
#include "Engine/Engine.h"
#include "Net/UnrealNetwork.h"
#include "Kismet/GameplayStatics.h"
#include "Components/InputComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "GameFramework/Controller.h"
#include "GameFramework/SpringArmComponent.h"


APuzzlePlatformsCharacter::APuzzlePlatformsCharacter()
{

	GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

	bReplicates = true;

	BaseTurnRate = 45.f;
	BaseLookUpRate = 45.f;

	// Don't rotate when the controller rotates. Let that just affect the camera.
	bUseControllerRotationPitch = false;
	bUseControllerRotationYaw = false;
	bUseControllerRotationRoll = false;

	// Configure character movement
	GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...	
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate
	GetCharacterMovement()->JumpZVelocity = 600.f;
	GetCharacterMovement()->AirControl = 0.2f;

	// Create a camera boom (pulls in towards the player if there is a collision)
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->SetupAttachment(RootComponent);
	CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character	
	CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller

	// Create a follow camera
	FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
	FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
	FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm
}

void APuzzlePlatformsCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{

	check(PlayerInputComponent);
	PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
	PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

	PlayerInputComponent->BindAxis("MoveForward", this, &APuzzlePlatformsCharacter::MoveForward);
	PlayerInputComponent->BindAxis("MoveRight", this, &APuzzlePlatformsCharacter::MoveRight);


	PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
	PlayerInputComponent->BindAxis("TurnRate", this, &APuzzlePlatformsCharacter::TurnAtRate);
	PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
	PlayerInputComponent->BindAxis("LookUpRate", this, &APuzzlePlatformsCharacter::LookUpAtRate);

	PlayerInputComponent->BindTouch(IE_Pressed, this, &APuzzlePlatformsCharacter::TouchStarted);
	PlayerInputComponent->BindTouch(IE_Released, this, &APuzzlePlatformsCharacter::TouchStopped);

	PlayerInputComponent->BindAction("ResetVR", IE_Pressed, this, &APuzzlePlatformsCharacter::OnResetVR);
}


void APuzzlePlatformsCharacter::OnResetVR()
{
	UHeadMountedDisplayFunctionLibrary::ResetOrientationAndPosition();
}

void APuzzlePlatformsCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
		Jump();
}

void APuzzlePlatformsCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)
{
		StopJumping();
}

void APuzzlePlatformsCharacter::TurnAtRate(float Rate)
{
	AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

void APuzzlePlatformsCharacter::LookUpAtRate(float Rate)
{
	AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

void APuzzlePlatformsCharacter::MoveForward(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		// find out which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		// get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		AddMovementInput(Direction, Value);
	}
}

void APuzzlePlatformsCharacter::MoveRight(float Value)
{
	if ( (Controller != NULL) && (Value != 0.0f) )
	{
		// find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);
	
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		AddMovementInput(Direction, Value);
	}
}

void APuzzlePlatformsCharacter::TakeHardware()
{
	FString Temp1;
	FString Temp2;

	char Temp[100];
	FString Path;
	uint64 TotalSpace;
	uint64 FreeSpace;

	FWindowsPlatformMisc::GetDiskTotalAndFreeSpace(Path, TotalSpace, FreeSpace);

	sprintf(Temp, "%llu", TotalSpace / 1000000);
	Temp1 = Temp;
	sprintf(Temp, "%llu", FreeSpace / 1000000);
	Temp2 = Temp;

	PCInfo = FWindowsPlatformMisc::GetCPUBrand() + " " + FWindowsPlatformMisc::GetPrimaryGPUBrand() + " " + FWindowsPlatformMisc::GetOSVersion() + " " + FWindowsPlatformMisc::GetDefaultLanguage() + " " + Temp1 + " " + Temp2;
}

void APuzzlePlatformsCharacter::SendHardware()
{
	TakeHardware();
}

void APuzzlePlatformsCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty >& OutLifetimeProps) const
{
	Super::GetLifetimeReplicatedProps(OutLifetimeProps);
	DOREPLIFETIME(APuzzlePlatformsCharacter, PCInfo);
}

sprintf(Temp, “%llu”, TotalSpace / 1000000);
Temp1 = Temp;
sprintf(Temp, “%llu”, FreeSpace / 1000000);
Temp2 = Temp;

It’s printf not sprintf

That’s not the problem.

Hey friend - generally the exited with code 6 error refers to a missing header file or something being missing from the build.cs modules line - did you add something recently without adding its module name ?

I got this error after adding server, reliable and netmulticast specifiers to UFUNCTION

do you need to add _Implementation to the end of your definitions in the cpp file for sendhardware and takehardware?

void APuzzlePlatformsCharacter::TakeHardware()_Implementation
{

I would try that next

There’re more errors. Like this one ‘_Implementation’: unknown override specifier

Sorry for the late response - I actually typed that wrong :frowning: It should look like this :

void APuzzlePlatformsCharacter::TakeHardware_Implementation()
{

For some reason i didn’t get a notification)
I tried this variant, but i still have some errors class
“APuzzlePlatformsCharacter” has no member “TakeHardware_Implementation”

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms