Skip to content

Commit

Permalink
Merge pull request #312 from AsgardEternal/upstream-track-playerconts
Browse files Browse the repository at this point in the history
Track playercontrollers for death logging
  • Loading branch information
werewolfboy13 committed Nov 2, 2023
2 parents 4ab1fd7 + 753fc17 commit def22e4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions squad-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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 =
Expand Down Expand Up @@ -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)
});

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit def22e4

Please sign in to comment.