Skip to content

Players missing at end of demo #334

Answered by saul
aldee07 asked this question in Questions
Nov 17, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

The reason is because the players disconnected before the demo finished recording. What you should do is capture player stats at the time they disconnect - see below for a complete example:

import * as assert from "assert";
import { Player, DemoFile } from "demofile";
import * as fs from "fs";

interface PlayerStats {
  team: string;
  steamId: string;
  playerName: string;
  kills: number;
  assists: number;
  deaths: number;
}

function parseDemoFile(path: string) {
  fs.readFile(path, (err, buffer) => {
    assert.ifError(err);

    const demoFile = new DemoFile();
    const stats: Record<string, PlayerStats> = {};

    function capturePlayerStats(player: Player) {
      // Skip over b…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@aldee07
Comment options

Answer selected by saul
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #333 on November 18, 2021 11:47.