Custom console function

Hello all !

I have a little problem, I’m unable to create a console command with parameters inplementable in blueprints …
I know how to create them without being in the console, how to make them in the console and BP without parameter, but when I had one the function isn’t compilable … It may be something like this, but it doesn’t want to compile …

UFUNCTION(Exec, BlueprintImplementableEvent, Category = "CmdAdmin")
void Kick(FString PlayerName);

I tried to replace FString with FString&, same error,
I tried to add virtual, it says I shouldn’t use virtual,

Please, it would be for something like “kick john” and john go out …

Thank you for reading !

Hi mdonge,

Looking at the documentation on the Console Manager makes it look like the Exec-style of console commands may be deprecated. That said, it also lead me to an answer: If you want arguments, you can use a function like this:

UFUNCTION(Exec, Category = "Console Command")
void Kick(const TArray<FString>& Players);

Then you can either enforce that only one player is given (e.g. not kick anyone and report an error if multiple players are specified) or iterate over the list kicking each player in turn.

For reference, you might also look at the information for IConsoleManager::RegisterConsoleCommand and/or FAutoConsoleCommands, since those appear to be the preferred way of setting up console commands. I wasn’t able to find quite all the documentation I’d like for them (esp. on the FConsoleCommandDelegate and related structures), but a quick “Go to definition” in Visual Studio let me infer what I needed.

Please let me know if this helps!

thanks ! I will look at this :wink:
I saw that they are deprecated, but I hope there was some workaround…