godotengine / godotengine/godot-docs

Add an example for `--server` argument in the dedicated server tutorial

Open
#10,789 1 comment 0 reactions 0 assignees View on GitHub
area:manual enhancement
Dominant language
reStructuredText
Stars
5.7k
Forks
3.8k
Avg merge
1d 20h
Merged PRs (30d)
25

Description

**Your Godot version:**
v4.4

**Issue description:**
The documentation for the dedicated server contains an example of the following code to differentiate between normal and dedicated server use.

```
if "--server" in OS.get_cmdline_user_args():
# Run your server startup code here...
#
# Using this check, you can start a dedicated server by running
# a Godot binary (editor or export template) with the `--server`
# command-line argument.
pass
```

However, during my tests the code does not work. Here is how I tested them.

**Godot script**
```
func _ready():
print("Starting game.")
print(OS.get_cmdline_args())
print(OS.get_cmdline_user_args())
if "--server" in OS.get_cmdline_args():
print("Started in server mode.")
```

**Output in ubuntu 22 LTS headless**
```
$ ./test.x86_64 --server --headless
Godot Engine v4.4.stable.official.4c311cbee - https://godotengine.org

Starting game.
["--server"]
[]
Started in server mode.
```

So in my tests I need to use `OS.get_cmdline_args()` to catch the `--server` argument. If I follow the documentation for dedicated servers, I get an empty array. As a new Godot user, I'm not sure if this is a bug in Godot, outdated documentation, or maybe just in my particular environment.

**URL to the documentation page:**
https://docs.godotengine.org/en/stable/tutorials/export/exporting_for_dedicated_servers.html
(maybe relevant) https://docs.godotengine.org/en/stable/classes/class_os.html

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.