diff --git a/squad-server/index.js b/squad-server/index.js index 5aa1bf58..490f0a7d 100644 --- a/squad-server/index.js +++ b/squad-server/index.js @@ -242,6 +242,8 @@ export default class SquadServer extends EventEmitter { this.logParser.on('PLAYER_WOUNDED', async (data) => { data.victim = await this.getPlayerByName(data.victimName); data.attacker = await this.getPlayerByName(data.attackerName); + if (!data.attacker) + data.attacker = await this.getPlayerByController(data.attackerPlayerController); if (data.victim && data.attacker) data.teamkill = @@ -257,6 +259,9 @@ export default class SquadServer extends EventEmitter { this.logParser.on('PLAYER_DIED', async (data) => { data.victim = await this.getPlayerByName(data.victimName); + data.attacker = await this.getPlayerByName(data.attackerName); + if (!data.attacker) + data.attacker = await this.getPlayerByController(data.attackerPlayerController); if (data.victim && data.attacker) data.teamkill = @@ -351,6 +356,9 @@ export default class SquadServer extends EventEmitter { players.push({ ...oldPlayerInfo[player.steamID], ...player, + playercontroller: this.logParser.eventStore.players[player.steamID] + ? this.logParser.eventStore.players[player.steamID].controller + : null, squad: await this.getSquadByID(player.teamID, player.squadID) }); @@ -542,6 +550,13 @@ export default class SquadServer extends EventEmitter { return this.getPlayerByCondition((player) => player.suffix === suffix, forceUpdate, false); } + async getPlayerByController(controller, forceUpdate) { + return this.getPlayerByCondition( + (player) => player.playercontroller === controller, + forceUpdate + ); + } + async pingSquadJSAPI() { if (this.pingSquadJSAPITimeout) clearTimeout(this.pingSquadJSAPITimeout);