mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 17:25:19 +01:00
Add KSP:DMP fixes #78
This commit is contained in:
parent
ca4ffe5614
commit
86422d576e
4 changed files with 41 additions and 1 deletions
|
@ -202,6 +202,7 @@ Games List
|
|||
* Killing Floor 2 (killingfloor2) [[Separate Query Port](#separate-query-port)]
|
||||
* Kingpin: Life of Crime (kingpin) [[Separate Query Port](#separate-query-port)]
|
||||
* KISS Psycho Circus (kisspc) [[Separate Query Port](#separate-query-port)]
|
||||
* DMP - KSP Multiplayer (kspdmp) [[Separate Query Port](#separate-query-port)]
|
||||
* KzMod (kzmod)
|
||||
* Left 4 Dead (left4dead)
|
||||
* Left 4 Dead 2 (left4dead2)
|
||||
|
|
|
@ -152,6 +152,7 @@ killingfloor|Killing Floor|killingfloor|port=7707,port_query_offset=1
|
|||
killingfloor2|Killing Floor 2|valve|port=7777,port_query=27015
|
||||
kingpin|Kingpin: Life of Crime|gamespy1|port=31510,port_query_offset=-10
|
||||
kisspc|KISS Psycho Circus|gamespy1|port=7777,port_query_offset=1
|
||||
kspdmp|DMP - KSP Multiplayer|kspdmp|port=6702,port_query_offset=1
|
||||
kzmod|KzMod|valve
|
||||
left4dead|Left 4 Dead|valve
|
||||
left4dead2|Left 4 Dead 2|valve
|
||||
|
|
38
protocols/kspdmp.js
Normal file
38
protocols/kspdmp.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
const request = require('request');
|
||||
|
||||
class Kspdmp extends require('./core') {
|
||||
run(state) {
|
||||
request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port_query,
|
||||
timeout: this.options.socketTimeout
|
||||
}, (e,r,body) => {
|
||||
if(e) return this.fatal('HTTP error');
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(body);
|
||||
} catch(e) {
|
||||
return this.fatal('Invalid JSON');
|
||||
}
|
||||
|
||||
for (const one of json.players) {
|
||||
state.players.push({name:one.nickname,team:one.team});
|
||||
}
|
||||
|
||||
for (const key of Object.keys(json)) {
|
||||
state.raw[key] = json[key];
|
||||
}
|
||||
state.name = json.server_name;
|
||||
state.maxplayers = json.max_players;
|
||||
if (json.players) {
|
||||
const split = json.players.split(', ');
|
||||
for (const name of split) {
|
||||
state.players.push({name:name});
|
||||
}
|
||||
}
|
||||
|
||||
this.finish(state);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Kspdmp;
|
|
@ -4,7 +4,7 @@ class Terraria extends require('./core') {
|
|||
run(state) {
|
||||
request({
|
||||
uri: 'http://'+this.options.address+':'+this.options.port_query+'/v2/server/status',
|
||||
timeout: 3000,
|
||||
timeout: this.options.socketTimeout,
|
||||
qs: {
|
||||
players: 'true',
|
||||
token: this.options.token
|
||||
|
|
Loading…
Reference in a new issue