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