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.

2 Likes

How did you figure all this out?

I am extremely lucky that I found your post on how to code your own dedicated server. I am a big game lover and I always wanted to create a place where I could freely play with my friends. At first I tried creating this kind of server but it did not work out. So I started asking my friends and relatives how can I fix this problem and they said that I would have to buy RDP to create this server. After that, I used your codes to initiate my dedicated server and it worked. Thank you so much, now I can invite all my friends to play games together and have fun.

Privacy & Terms