Skip to content

Error on count rounds and player stats #260

Answered by saul
basmoura asked this question in Questions
Discussion options

You must be logged in to vote

Something like:

let roundNumber = 1;

function logScores() {
  const teams = demoFile.teams;
  const terrorists = teams[2];
  const cts = teams[3];

  const rounds = terrorists.score + cts.score;
  const tr_score = terrorists.score;
  const ct_score = cts.score;

  console.log(`ROUND NUMBER: ${rounds}`);
  console.log(`CT : ${ct_score} vs T : ${tr_score}`);
  console.log("\n");
}

demoFile.gameEvents.on("round_start", (e) => {
  roundNumber += 1;
  logScores();
});

demoFile.on("end", (e) => {
  if (e.error) {
    console.error("Error during parsing:", e.error);
  } else {
    logScores();
  }
  console.log("Finished.");
});

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by saul
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants
Converted from issue

This discussion was converted from issue #135 on February 28, 2021 14:00.