node-gamedig/README.md

91 lines
2.1 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
```
2013-07-12 11:18:55 +02:00
### Input Parameters
* **type**: One of the types from the protocols folder
* **host**
2013-07-12 11:20:17 +02:00
* **port**: (optional) Uses the protocol default if not set
* **login**: (optional) Used only by nadeo protocol
* **password**: (optional) Used only by nadeo protocol
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
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-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
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
2013-07-12 11:18:55 +02:00
* \+ others
2013-07-11 11:13:39 +02:00
* Nadeo Protocol
2013-07-11 11:25:49 +02:00
* Trackmania Forever
* Trackmania 2
* Shootmania
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
2013-07-12 11:18:55 +02:00
* \+ others
2013-07-12 15:33:57 +02:00
* Terraria (tshock)
2013-07-11 11:13:39 +02:00
* Unreal 2 Protocol
2013-07-11 11:25:49 +02:00
* Killing Floor
* Unreal Tournament 2004