How to add new console command

Following the model provided in the ShooterGame, I have created my own CheatManager, but the method is not executed, although it does show up in the console auto-suggest listing. Any ideas on what I have missed?

inside BTCheatManager.h

// Copyright 2013 Gneu, LLC. All Rights Reserved.

#pragma once

#include "BTCheatManager.generated.h"

/**
 * 
 */
UCLASS(Within=BetterTechPlayerController)
class UBTCheatManager : public UCheatManager
{
	GENERATED_UCLASS_BODY()

	UFUNCTION(exec)
	void AddFunds(int32 value);

	UFUNCTION(exec)
	void Cheat(const FString& Msg);	
};

inside BTCheatManager.cpp

// Copyright 2013 Gneu, LLC. All Rights Reserved.

#include "BetterTech.h"

UBTCheatManager::UBTCheatManager(const class FPostConstructInitializeProperties& PCIP) : Super(PCIP)
{
}

void UBTCheatManager::AddFunds(int32 value)
{
	ABetterTechPlayerController* MyPC = Cast(GetOuter());
	check(MyPC);

	ABTPRI* MyPRI = Cast(MyPC->PlayerReplicationInfo);
	if (MyPRI && MyPRI->Role == ROLE_Authority)
	{
		MyPRI->SetFunds(MyPRI->GetFunds() + value);
		MyPC->ClientMessage(FString::Printf(TEXT("Funds changed to: %d"), MyPRI->GetFunds()));
	}
}

void UBTCheatManager::Cheat(const FString& Msg)
{
	ABetterTechPlayerController* MyPC = Cast(GetOuter());
	check(MyPC);

	MyPC->ServerCheat(Msg.Left(128));
}

inside BetterTechPlayerController.cpp

// Copyright 2013 Gneu, LLC. All Rights Reserved.

#include "BetterTech.h"

ABetterTechPlayerController::ABetterTechPlayerController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	PlayerCameraClass = ABTPlayerCamera::StaticClass();
	CheatClass = UBTCheatManager::StaticClass();
}

void ABetterTechPlayerController::ServerCheat_Implementation(const FString& Msg)
{
	if (CheatManager)
	{
		ClientMessage(ConsoleCommand(Msg));
	}
}

inside BetterTech.log

[0012.57] Command not recognized: AddFunds 4
[0050.29] Command not recognized: AddFunds 4
[0053.63] Command not recognized: AddFunds 4
[0056.65] Command not recognized: AddFunds 4000

The above works out swell, as long as you are loading the correct gameinfo. I was having my entrygame loaded which did not derive. All is well now.

that’s great to know!

that we can add new console commands !

thanks for sharing your research :slight_smile:

You can (and probably should) even have different commands available when in different game modes. =) You are very welcome (Dont forget to upvote good answers!).

Is it possible to add new console commands through blueprint somehow?

Stupid question time.

How to load “correct gameinfo”? :smiley: I can see my it in auto-suggests list, but command is not recognized.