node-gamedig/README.md

97 lines
2.3 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 11:18:55 +02:00
* **name**
* **map**
* **password**: Boolean
* **maxplayers**
2013-07-12 11:23:40 +02:00
* **players**: (array of objects) Each object may contain name, ping, score, team, address
2013-07-12 11:18:55 +02:00
* **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
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-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.