Pass string parameter to function via custom blueprint node.

I have a custom blueprint node that runs a function to spawn another instance of my dedicated server. I would like to be able to specify the port number through my blueprint. I can pass the port as a string from the blueprint, but I don’t know how to insert that parameter into the actual function.


FPlatformProcess::CreateProc(TEXT("C:\\MyGame\\MyDedicatedServer.exe"), TEXT("MyLevel -log PORT = ????"), true, false, false, nullptr, 0, nullptr, nullptr);

I’m sure this is very basic stuff but my knowledge of C++ at this point is minimal. Thanks!

There’s a number of ways you can do this (sprintf into a raw buffer and then convert that), but if you want to use FText, it looks like you can just use FText::Format(…)

Thanks! To simplify it for myself, I now pass the entire server parameters instead of just the port. It works fine but since you said there’s a number of ways to do this, is there anything wrong with this?



//Run Server
void UMyBlueprintFunctionLibrary::RunDedicatedServer(FString serversettings)
{
	const TCHAR* fullsettings = *serversettings;
	FPlatformProcess::CreateProc(TEXT("C:\\MyGame\\MyServer.exe"), fullsettings, true, false, false, nullptr, 0, nullptr, nullptr);
}


I don’t think there’s anything wrong with that, but I’m not running a dedicated server or anything like that. If it works for you then go with it! :slight_smile: