2019-01-09 12:35:11 +01:00
|
|
|
const Quake2 = require('./quake2');
|
2018-02-13 11:07:31 +01:00
|
|
|
|
2019-01-07 01:52:03 +01:00
|
|
|
class FiveM extends Quake2 {
|
2017-08-10 13:49:42 +02:00
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.sendHeader = 'getinfo xxx';
|
|
|
|
this.responseHeader = 'infoResponse';
|
2018-05-05 10:31:25 +02:00
|
|
|
this.encoding = 'utf8';
|
2017-08-10 13:49:42 +02:00
|
|
|
}
|
2018-02-13 11:07:31 +01:00
|
|
|
|
2019-01-09 12:35:11 +01:00
|
|
|
async run(state) {
|
|
|
|
await super.run(state);
|
2018-02-13 11:07:31 +01:00
|
|
|
|
2019-01-09 12:35:11 +01:00
|
|
|
{
|
|
|
|
const raw = await this.request({
|
2019-01-12 11:43:36 +01:00
|
|
|
uri: 'http://' + this.options.address + ':' + this.options.port + '/info.json'
|
2019-01-09 12:35:11 +01:00
|
|
|
});
|
|
|
|
const json = JSON.parse(raw);
|
2018-02-13 11:07:31 +01:00
|
|
|
state.raw.info = json;
|
2019-01-09 12:35:11 +01:00
|
|
|
}
|
2018-02-13 11:07:31 +01:00
|
|
|
|
2019-01-09 12:35:11 +01:00
|
|
|
{
|
|
|
|
const raw = await this.request({
|
2019-01-12 11:43:36 +01:00
|
|
|
uri: 'http://' + this.options.address + ':' + this.options.port + '/players.json'
|
2018-02-13 11:07:31 +01:00
|
|
|
});
|
2019-01-09 12:35:11 +01:00
|
|
|
const json = JSON.parse(raw);
|
|
|
|
state.raw.players = json;
|
|
|
|
state.players = [];
|
|
|
|
for (const player of json) {
|
|
|
|
state.players.push({name: player.name, ping: player.ping});
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 11:07:31 +01:00
|
|
|
}
|
2017-08-10 13:49:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = FiveM;
|