# gamedig

[GameDig](https://github.com/gamedig/node-gamedig) is a tool that queries game servers and returns outputs data from a query into json format. It can not only check if the game server is online but also return various data such as current maps and players. This allows `./gameserver details` to display live information.

GameDig super-seeds gsquery as the tool to monitor game servers. GameDig is currently optional but recommended and gsquery is kept to ensure compatibility as gamedig requires Node.js to be installed.

## Install Node.js

GameDig requires [Node.js](https://nodejs.org) a JavaScript runtime environment installed to work. Use the following instructions to install Node.js.

### Remove existing NodeJS

If you already have an older version of nodejs installed or be having issues with node dependencies. It may be worth reinstalling Node.js.

#### Ubuntu/Debian

```
sudo apt remove --purge nodejs npm
sudo apt clean
sudo apt autoclean
sudo apt install -f
sudo apt autoremove
```

#### CentOS

{% hint style="warning" %}
Work in progress
{% endhint %}

### Install NodeJS

Installing nodejs can be problematic, however, using the below should work well.

#### Ubuntu/Debian

{% embed url="<https://github.com/nodesource/distributions#ubuntu-versions>" %}

{% embed url="<https://github.com/nodesource/distributions#debian-versions>" %}

#### Enterprise Linux Based Distributions

{% embed url="<https://github.com/nodesource/distributions#enterprise-linux-based-distributions>" %}

### Install GameDig npm

Once nodejs is installed use npm to install gamedig with the following command.

```
npm install gamedig -g
```

## Update GameDig

Updates to GameDig are regularly made. It is possible to update by running the npm update command.

```
npm update -g
```

You can also see which version of gamedig is installed by running the following.

```
 npm list -g gamedig
```

## Sample output

### Details

Extra info becomes available for game server details.

```
Players:          0/8
Current Map:      Outpost
```

## Raw output

```
gamedig --type "protocol-valve" --host "1.2.3.4" --port "27015"
```

```
{
  "name": "LinuxGSM Server",
  "map": "StationKappa",
  "password": false,
  "raw": {
    "protocol": 17,
    "folder": "StickyBots",
    "game": "StickyBots",
    "steamappid": 0,
    "numplayers": 0,
    "numbots": 0,
    "listentype": "d",
    "environment": "l",
    "secure": 0,
    "version": "0.0.6.22",
    "port": 7777,
    "steamid": "90122418420694019",
    "tags": "BUILDID:622,OWNINGID:90122418420694019,OWNINGNAME:LinuxGSM Server,P2PADDR:90122418420694019,P2PPORT:7777,SESSIONFLAGS:171",
    "gameid": "889400",
    "rules": {
      "BUILDID_i": "622",
      "NP_i": "0",
      "OWNINGID": "90122418420694019",
      "OWNINGNAME": "LinuxGSM Server",
      "P2PADDR": "90122418420694019",
      "P2PPORT": "7777",
      "SESSIONFLAGS": "171",
      "SN_s": "LinuxGSM Server"
    }
  },
  "maxplayers": 8,
  "players": [],
  "bots": [],
  "query": {
    "host": "1.2.3.4",
    "address": "1.2.3.4",
    "port": 27015,
    "port_query": 27015,
    "type": "protocol-valve",
    "duration": 90,
    "attempts": 1
  }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.linuxgsm.com/requirements/gamedig.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
