Added onlineplayers

Added onlineplayers which utilizes the length of the players array to
make it always available.

Possible to add bots to this count but i think just players would be
best.

Updated readme to include this change.
This commit is contained in:
xCausxn 2015-02-21 17:21:56 +00:00
parent 9c785bcda0
commit 4d31e29e70
2 changed files with 13 additions and 8 deletions

View File

@ -54,6 +54,7 @@ Otherwise, the returned object is guaranteed to contain the following keys:
* **name** * **name**
* **map** * **map**
* **password**: Boolean * **password**: Boolean
* **onlineplayers**
* **maxplayers** * **maxplayers**
* **players**: (array of objects) Each object **may** contain name, ping, score, team, address * **players**: (array of objects) Each object **may** contain name, ping, score, team, address
* **bots**: Same schema as players * **bots**: Same schema as players

View File

@ -42,6 +42,7 @@ module.exports = Class.extend(EventEmitter,{
raw: {}, raw: {},
onlineplayers: 0,
maxplayers: 0, maxplayers: 0,
players: [], players: [],
bots: [] bots: []
@ -61,6 +62,9 @@ module.exports = Class.extend(EventEmitter,{
if(this.options.notes) if(this.options.notes)
state.notes = this.options.notes; state.notes = this.options.notes;
//Additional Conditionals
if('players' in state) state.onlineplayers = state.players.length;
state.query = {}; state.query = {};
if('host' in this.options) state.query.host = this.options.host; if('host' in this.options) state.query.host = this.options.host;
if('address' in this.options) state.query.address = this.options.address; if('address' in this.options) state.query.address = this.options.address;