Calling Custom Console Commands

A simple question
i call “t.MaxFPS 60” from console and it sets max fps to 60. So i assumed i would call an exec function with one param which is FString from console like this “SomeCommand SomeString”, but it didn’t worked.

Here it is

// Class is derived from AActor

// Header
UFUNCTION(Exec, Category = IPC)
void SendCommandToCE(const FString Command);

// Source
void ACECommunication::SendCommandToCE(const FString Command)
{
	if (CEProcess)
	{
		CEProcess->WriteWhenReady(Command);
	}
}

Then i tried calling it from console like this “SendCommandToCE something” and it gives me “Command not recognized : SendCommandToCE uci”

I tried putting it between quotes since it is a string but the same. How can i call this?

Ok, i change the question. How do you create exec commands from scratch?

I know that Execs can be placed in specific places. I know it will work when You add them to PlayerController or to the GameInstance (and maybe GameEngine).

I don’t think it will work in any Actor.

Aside of Exec, there Command Delegates, but not sure how to use them, check commands in editor and search command in github to get examples. Here few examples that i found:

https://github.com/EpicGames/UnrealEngine/blob/8a80b5541f69a79abf5855668f39e1d643717600/Engine/Source/Runtime/Landscape/Private/LandscapeRender.cpp#L397

This one seems easier:

https://github.com/EpicGames/UnrealEngine/blob/e607ba4d978c08a26e8e8e629dec0884bb161770/Engine/Plugins/Experimental/BlueprintStats/Source/BlueprintStats/Private/BlueprintStatsModule.cpp#L38

You can also hook up to Exec() in your own UGameViewportClient

https://github.com/EpicGames/UnrealEngine/blob/8a80b5541f69a79abf5855668f39e1d643717600/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp#L1989

Just remember too add Super::Exec at the end of it or else you will kill off lot of commands. Also this method won’t work with auto complete, you will need to add stuff in Input.ini

https://github.com/EpicGames/UnrealEngine/blob/8a80b5541f69a79abf5855668f39e1d643717600/Engine/Config/BaseInput.ini#L47

Just found this, after you have answered. Console Varaibles C++ In Unreal Engine | Unreal Engine 5.2 Documentation

There says: By registering console commands and variables in the console manager you get auto completion and enumeration to get a list of all console objects (console command Help or DumpConsoleVariables). Because of this, you should avoid the old Exec interface

Sigh… It should say the same inside UFUNCTION() page. But it doesnt. Sometimes how slow UE Doc is updated kills me.

Thank you for answering.