2013-07-10 12:02:48 +02:00
|
|
|
node-GameDig - Game Server Query Library
|
2013-07-10 12:07:12 +02:00
|
|
|
---
|
2013-07-10 12:02:48 +02:00
|
|
|
|
2014-01-31 23:27:52 +01:00
|
|
|
Usage from Node.js
|
2013-07-10 12:02:48 +02:00
|
|
|
---
|
|
|
|
|
2013-07-11 11:25:49 +02:00
|
|
|
```shell
|
2013-07-10 14:23:18 +02:00
|
|
|
npm install gamedig
|
|
|
|
```
|
|
|
|
|
2013-07-10 12:02:48 +02:00
|
|
|
```javascript
|
|
|
|
var Gamedig = require('gamedig');
|
2013-07-10 14:23:18 +02:00
|
|
|
Gamedig.query(
|
|
|
|
{
|
|
|
|
type: 'minecraft',
|
|
|
|
host: 'mc.example.com'
|
|
|
|
},
|
|
|
|
function(state) {
|
2013-07-10 12:02:48 +02:00
|
|
|
if(state.error) console.log("Server is offline");
|
|
|
|
else console.log(state);
|
|
|
|
}
|
2013-07-10 14:23:18 +02:00
|
|
|
);
|
2013-07-10 12:02:48 +02:00
|
|
|
```
|
|
|
|
|
2013-07-12 11:18:55 +02:00
|
|
|
### Input Parameters
|
|
|
|
|
2014-01-31 23:27:52 +01:00
|
|
|
* **type**: One of the game IDs listed in the game list below
|
2013-07-12 11:18:55 +02:00
|
|
|
* **host**
|
2013-07-12 11:20:17 +02:00
|
|
|
* **port**: (optional) Uses the protocol default if not set
|
2013-07-12 11:23:40 +02:00
|
|
|
* **notes**: (optional) Passed through to output
|
2013-07-12 11:18:55 +02:00
|
|
|
|
|
|
|
###Callback Function
|
2013-07-12 11:15:11 +02:00
|
|
|
|
2013-07-12 11:12:02 +02:00
|
|
|
The callback function is "guaranteed" to be called exactly once.
|
2013-07-10 12:06:44 +02:00
|
|
|
|
2013-07-12 11:12:02 +02:00
|
|
|
If an error occurs, the returned object will contain an "error" key, indicating the issue.
|
|
|
|
If the error key exists, it should be assumed that the game server is offline or unreachable.
|
|
|
|
|
2013-07-12 11:12:55 +02:00
|
|
|
Otherwise, the returned object is guaranteed to contain the following keys:
|
2013-07-10 12:02:48 +02:00
|
|
|
|
2013-07-12 15:29:25 +02:00
|
|
|
**Stable, always present:**
|
2013-07-12 15:33:57 +02:00
|
|
|
|
2013-07-12 11:18:55 +02:00
|
|
|
* **name**
|
|
|
|
* **map**
|
|
|
|
* **password**: Boolean
|
|
|
|
* **maxplayers**
|
2013-07-12 15:29:25 +02:00
|
|
|
* **players**: (array of objects) Each object **may** contain name, ping, score, team, address
|
|
|
|
* **bots**: Same schema as players
|
2013-07-12 11:18:55 +02:00
|
|
|
* **notes**: Passed through from the input
|
2013-07-12 15:29:25 +02:00
|
|
|
|
|
|
|
**Unstable, not guaranteed:**
|
2013-07-12 15:33:57 +02:00
|
|
|
|
2013-07-12 15:29:25 +02:00
|
|
|
* **raw**: Contains all information received from the server
|
2013-07-12 11:18:55 +02:00
|
|
|
* **query**: Details about the query performed
|
2013-07-11 11:13:39 +02:00
|
|
|
|
2013-07-12 11:12:02 +02:00
|
|
|
It can usually be assumed that the number of players online is equal to the length of the players array.
|
|
|
|
Some servers may return an additional player count number, which may be present in the unstable raw object.
|
2013-07-10 12:02:48 +02:00
|
|
|
|
|
|
|
Supported Games
|
|
|
|
---
|
2013-10-12 08:43:16 +02:00
|
|
|
|
2014-01-31 23:27:52 +01:00
|
|
|
* Alien Swarm (alienswarm)
|
|
|
|
* Armagetron (armagetron)
|
|
|
|
* Build and Shoot (buildandshoot)
|
|
|
|
* Counter-Strike 1.6 (cs16)
|
|
|
|
* Counter-Strike: Source (css)
|
|
|
|
* Counter-Strike: Global Offensive (csgo)
|
|
|
|
* Dino D-Day (dinodday)
|
|
|
|
* Garry's Mod (garrysmod)
|
|
|
|
* The Hidden: Source (hidden)
|
|
|
|
* Just Cause Multiplayer (jcmp)
|
|
|
|
* Killing Floor (killingfloor)
|
|
|
|
* KzMod (kzmod)
|
|
|
|
* Left 4 Dead (left4dead)
|
|
|
|
* Left 4 Dead 2 (left4dead2)
|
|
|
|
* Minecraft (minecraft)
|
|
|
|
```
|
|
|
|
Some minecraft servers may not respond to a typical status query. If this is the case, try using the
|
|
|
|
'minecraftping' server type instead, which uses a less accurate but more reliable solution.
|
|
|
|
```
|
|
|
|
* Mutant Factions (mutantfactions)
|
|
|
|
* Natural Selection (ns)
|
|
|
|
* Natural Selection 2 (ns2)
|
|
|
|
* No More Room in Hell (nmrih)
|
|
|
|
* Nuclear Dawn (nucleardawn)
|
|
|
|
* Quake 2 (quake2)
|
|
|
|
* Quake 3 (quake3)
|
|
|
|
* Ricochet (ricochet)
|
|
|
|
* Rust (rust)
|
|
|
|
* The Ship (ship)
|
|
|
|
* ShootMania (shootmania)
|
2013-10-12 08:43:16 +02:00
|
|
|
```
|
|
|
|
Requires additional parameters: login, password
|
|
|
|
```
|
2014-01-31 23:27:52 +01:00
|
|
|
* Starbound (starbound)
|
|
|
|
* Suicide Survival (suicidesurvival)
|
|
|
|
* Sven Coop (svencoop)
|
|
|
|
* Synergy (synergy)
|
|
|
|
* Team Fortress 2 (tf2)
|
|
|
|
* Terraria (terraria)
|
|
|
|
```
|
|
|
|
Requires tshock server mod, and an additional parameter: token
|
|
|
|
```
|
|
|
|
* TrackMania 2 (trackmania2)
|
|
|
|
```
|
|
|
|
Requires additional parameters: login, password
|
|
|
|
```
|
|
|
|
* TrackMania Forever (trackmaniaforever)
|
|
|
|
```
|
|
|
|
Requires additional parameters: login, password
|
|
|
|
```
|
|
|
|
* Unreal Tournament 2004 (ut2004)
|
|
|
|
* Unreal Tournament 3 (ut3)
|
|
|
|
* Warsow (warsow)
|
|
|
|
|
|
|
|
Don't see your game listed here?
|
|
|
|
1. Let us know so we can fix it
|
|
|
|
2. You can try using some common query protocols directly by using one of these server types:
|
|
|
|
* protocol-gamespy3
|
|
|
|
* protocol-nadeo
|
|
|
|
* protocol-quake2
|
|
|
|
* protocol-quake3
|
|
|
|
* protocol-unreal2
|
|
|
|
* protocol-valve
|
|
|
|
* protocol-valvegold
|
|
|
|
|
|
|
|
Usage from Command Line
|
|
|
|
---
|
2013-10-12 08:43:16 +02:00
|
|
|
|
2014-01-31 23:27:52 +01:00
|
|
|
Want to integrate server queries from a batch script or other programming language?
|
|
|
|
You'll still need npm to install gamedig:
|
|
|
|
```shell
|
|
|
|
npm install gamedig -g
|
2013-10-12 08:43:16 +02:00
|
|
|
```
|
2014-01-31 23:27:52 +01:00
|
|
|
|
|
|
|
After installing gamedig globally, you can call gamedig via the command line
|
|
|
|
using the same parameters mentioned in the API above:
|
|
|
|
```shell
|
|
|
|
gamedig --type minecraft --host mc.example.com --port 11234
|
2013-10-12 08:43:16 +02:00
|
|
|
```
|
|
|
|
|
2014-01-31 23:27:52 +01:00
|
|
|
The output of the command will be in JSON format.
|