mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-18 01:30:39 +01:00
da7a4a6334
* Remove Players Set Num * Stabilize numplayers on armagetron * Stabilize numplayers on ase * Stabilize numplayers on assettocorsa * Optimize away a variable declaration * Stabilize numplayers on buildandshoot * Stabilize numplayers on cs2d * Fix wrong raw field parsed on Doom3 * Updated CHANGELOG and README regarding doom3 fix and numplayers * Stabilize numplayers on doom3 * Stabilize numplayers on eco * Stabilize numplayers on ffow * Stabilize numplayers on quake2 * Stabilize numplayers on gamespy1 * Stabilize numplayers on gamespy2 * Stabilize numplayers on gamespy3 * Remove reductant numplayers setter in jc2mp * Stabilize numplayers on kspdmp * Stabilize numplayers on mafia2mp * Stabilize numplayers on minecraftvanilla and remove players empty placeholders * Stabilize numplayers on nadeo * Stabilize numplayers on samp and reduce unused setters * Stabilize numplayers on terraria * Stabilize numplayers on tribes1 * Stabilize numplayers on unreal2 * Stabilize numplayers on valve * Stabilize numplayers on ventrilo * Battlefield: Set numplayers from info, not players * Stabilize numplayers on minecraft * Stabilize numplayers on teamspeak2 * Stabilize numplayers on teamspeak3 * Update CHANGELOG.md to add removal of players placeholders * Replaced minecraft gamespy numplayers
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
import Core from './core.js'
|
|
|
|
export default class assettocorsa extends Core {
|
|
async run (state) {
|
|
const serverInfo = await this.request({
|
|
url: `http://${this.options.address}:${this.options.port}/INFO`,
|
|
responseType: 'json'
|
|
})
|
|
const carInfo = await this.request({
|
|
url: `http://${this.options.address}:${this.options.port}/JSON|${parseInt(Math.random() * 999999999999999, 10)}`,
|
|
responseType: 'json'
|
|
})
|
|
|
|
if (!serverInfo || !carInfo || !carInfo.Cars) {
|
|
throw new Error('Query not successful')
|
|
}
|
|
|
|
state.maxplayers = serverInfo.maxclients
|
|
state.name = serverInfo.name
|
|
state.map = serverInfo.track
|
|
state.password = serverInfo.pass
|
|
state.gamePort = serverInfo.port
|
|
state.raw.carInfo = carInfo.Cars
|
|
state.raw.serverInfo = serverInfo
|
|
|
|
for (const car of carInfo.Cars) {
|
|
if (car.IsConnected) {
|
|
state.players.push({
|
|
name: car.DriverName,
|
|
car: car.Model,
|
|
skin: car.Skin,
|
|
nation: car.DriverNation,
|
|
team: car.DriverTeam
|
|
})
|
|
}
|
|
}
|
|
|
|
state.numplayers = carInfo.Cars.length
|
|
}
|
|
}
|