node-gamedig/README.md

89 lines
2.0 KiB
Markdown
Raw Normal View History

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
Usage
---
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
```
Callback Function
2013-07-10 12:02:48 +02:00
---
The callback function is "guaranteed" to be called exactly once.
2013-07-10 12:06:44 +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-11 11:13:39 +02:00
* name
2013-07-10 12:02:48 +02:00
* map
* password (boolean)
* maxplayers
* players (may contain name, ping, score, team, address)
* bots (same as players)
* raw (contains special keys depending on the type of server queried - UNSTABLE)
* notes (passed through from the input)
* query (details about the query performed)
* host
* address
* port
* type
* pretty (a "pretty" string describing the game)
2013-07-11 11:13:39 +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
---
* Armagetron
* Gamespy 3 Protocol
2013-07-11 11:25:49 +02:00
* Minecraft
* Unreal Tournament 3
2013-07-10 12:02:48 +02:00
* GoldSrc Engine
2013-07-11 11:25:49 +02:00
* Half Life: Death Match
* Ricochet
* Counter-Strike: 1.6
* + others
2013-07-11 11:13:39 +02:00
* Nadeo Protocol
2013-07-11 11:25:49 +02:00
* Trackmania Forever
* Trackmania 2
* Shootmania
* (requires additional 'login' and 'password' parameters for User login on server)
2013-07-11 11:13:39 +02:00
* Quake 2 Protocol
2013-07-11 11:25:49 +02:00
* Quake 2
2013-07-11 11:13:39 +02:00
* Quake 3 Protocol
2013-07-11 11:25:49 +02:00
* Quake 3 Arena
* Quake 3 Team Arena
* Warsow
2013-07-11 11:13:39 +02:00
* Source Engine
2013-07-11 11:25:49 +02:00
* Counter-Strike: Source
* Counter-Strike: Global Offensive
* Team Fortress 2
* + others
2013-07-11 11:13:39 +02:00
* Tshock Protocol
2013-07-11 11:25:49 +02:00
* Terraria
2013-07-11 11:13:39 +02:00
* Unreal 2 Protocol
2013-07-11 11:25:49 +02:00
* Killing Floor
* Unreal Tournament 2004
2013-07-10 12:02:48 +02:00
Unstable API
---
The contents of the returned state object may change slightly from build to build, as the API
is still being formed.