A Better Solution to Console Command Implementation in BP?

So I have scoured AnswerHub and the UE Forums for a few days, slogging through far dated answers and suggestions on how to implement custom console commands but most of them are, as stated, out-dated and deprecated. Through some testing I came up with a small workaround but I’d like to know of an easier way, or a less obscure way since there seems to be no direct answers nor any updated tutorials on the matter.

Here’s the solution I came up with:

In MyGameInstance.h file I put in:

UFUNCTION(exec, BlueprintCallable, ...)
virtual void functionName(...);

void ReceiveFunctionName(...);

NOTE: Dont mind the ellipses, you can put in whatever need be. Same for the virtual and return type specifiers.

  • First, I declare a function flagged with “exec” to make it callable during runtime through the game’s console. BlueprintCallable is optional and meant to just make the function callable in blueprint should you need to.
  • Next is a function declared with “BlueprintImplementableEvent”. This is so this function is not natively defined in C++ but will be defined in Blueprints.

In MyGameInstance.cpp file:

void UMyGameInstance::functionName(...)
     // Authentication if necessary, ie. make sure passed-in parameters are valid

  • Here we define the exec function. In my implementation, for the authentication section, I make sure that the parameter is not null (or empty in the case of a string). You can input any other preauthentication you desire here.
  • Lastly, we call the ReceiveFunctionName() function that we will define in Blueprints later.

Now I know this isn’t the best way to handle console commands, nor is it probably the safest, but when there is only ancient (2015 articles are ancient history in most cases!) answers to be found and only API references that show things like FAutoConsoleCommand but not HOW to use it, the best I could do was improvise!

So I leave this to the more well-versed in the tongue of UE4 magic. Please weigh in and tell me, and the rest of the community, a way to better implement console commands through Blueprints.

Can I ask what you require the console commands for?

The typical testing of variables and functionality, along with wanting to add in cheats later on. I do realize there is a CheatManager but according to the API it is only available during development and is removed once you do a shipping build.

The console is also removed in shipping mode.
To have the functionality you are describing above, I would implement my own Slate UI console (text edit box), parse the input through a text widget and simply call the functions in code (or through BP however you set it up).