track playercontrollers for death logging

This commit is contained in:
Skillet 2023-11-02 01:14:05 -04:00
parent 4ab1fd73e7
commit 753fc17e6a

View File

@ -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);