VSCode Tasks to Run Dedicated Server/Clients

Edit your tasks.json and add two new tasks:

{
            "label": "CoopGame Win64 Dedicated Server",
            "group": "none",
            "command": "Engine\\Binaries\\Win64\\UE4Editor.exe",
            "args": [
                "E:\\Projects\\Unreal\\CoopGame\\CoopGame.uproject",
                "/Game/Levels/P_MainMap?listen",
                "-server",
                "-log"
            ],
            "problemMatcher": "$msCompile",
            "type": "shell",
            "options": {
                "cwd": "E:\\Epic\\UE_4.25"
            },
	   "presentation": {
	       "reveal": "always",
	    },
        },
        {
            "label": "CoopGame Win64 Client",
            "group": "none",
            "command": "Engine\\Binaries\\Win64\\UE4Editor.exe",
            "args": [
                "E:\\Projects\\Unreal\\CoopGame\\CoopGame.uproject",
                "127.0.0.1:7777",
                "-game",
                "-log"
            ],
            "problemMatcher": "$msCompile",
            "type": "shell",
            "options": {
                "cwd": "E:\\Epic\\UE_4.25",
            },
            "presentation": {
                "reveal": "always"
            },
	   "runOptions": {
	       "instanceLimit": 10
	   }
        }

Remember to change the CWD path to your engine’s path, also change the project name and the Map path. The client is connecting directly to the localhost (127.0.0.1) port 7777.
You can change the instanceLimit of the Client Task, it means the maximum numbers of
clients running simultaneously.

OPTIONAL: Bind a specific key to run the tasks directly from a shortcut:
Edit your VSCode keybindings.json and add the new bindings:

// Place your key bindings in this file to override the defaults
[
    {
        "key": "alt+n",
        "command": "workbench.action.tasks.runTask",
        "args": "CoopGame Win64 Dedicated Server"
    },
    {
        "key": "alt+m",
        "command": "workbench.action.tasks.runTask",
        "args": "CoopGame Win64 Client"
    },
]

Remember to change the key and the args, args is the task name from tasks.json.

1 Like

How did you figure all this out?