From 753fc17e6add15a285a0ea10662f17aad125d7d9 Mon Sep 17 00:00:00 2001 From: Skillet Date: Thu, 2 Nov 2023 01:14:05 -0400 Subject: [PATCH] track playercontrollers for death logging --- squad-server/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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);