-
Describe the bug Code to reproduce // get score for ct and tr
demoFile.gameEvents.on("round_officially_ended", e => {
const teams = demoFile.teams;
const terrorists = teams[2];
const cts = teams[3];
gameData.rounds = terrorists.score + cts.score
gameData.tr_score = terrorists.score
gameData.ct_score = cts.score
}); // get player data
demoFile.gameEvents.on("round_end", e => {
let roundNumber = demoFile.gameRules.roundsPlayed - 1;
let players = demoFile.players.map(p => p.userId)
let player = ""
let playerData = {}
for (p of players) {
player = demoFile.entities.getByUserId(p)
if (player.steam64Id === '0') { continue; }
playerData = {
steam_id: player.steam64Id,
player: player.name,
kills: player.kills,
assists: player.assists,
deaths: player.deaths,
mvps: player.mvps,
score: player.score,
side: ''
}
if (gameData.players.some(p => p.steam_id === player.steam64Id)) {
let playerFound = gameData.players.find(p => p.steam_id === player.steam64Id)
if (player.kills > playerFound.kills || player.deaths > playerFound.deaths || player.assists > playerFound.assists || player.mvps > playerFound.mvps) {
gameData.players = gameData.players.filter(p => p.steam_id != player.steam64Id)
gameData.players.push(playerData)
}
} else {
gameData.players.push(playerData)
}
} Expected behaviour |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
Demo files are very often missing events. You have to interpolate them in some way. There is nothing this library can do to fix this. The same happens with demoinfo and c# demoinfo. |
Beta Was this translation helpful? Give feedback.
-
If this also happens with demoinfo, unfortunately there's nothing we can do here. |
Beta Was this translation helpful? Give feedback.
-
@basmoura I don't think they are missing events, just that the score updates after the next round, which means a GOTV pro game is often closed before the new score have updated, take a look at this screenshot where I thought that I was missing the last round too.
|
Beta Was this translation helpful? Give feedback.
-
Instead of incrementing round count on round end, why not do it on round start (and start at 0)? Then you can treat the demo ending as end of the final round |
Beta Was this translation helpful? Give feedback.
-
Do you have idea for fix? (final score 16:0) Code let roundNumber = 1;
demoFile.gameEvents.on("round_start", e => {
roundNumber += 1;
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');
}); Output
|
Beta Was this translation helpful? Give feedback.
-
See my previous comment - you're not treating the demo ending as the end of the final round |
Beta Was this translation helpful? Give feedback.
-
What should I put instead of |
Beta Was this translation helpful? Give feedback.
-
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.");
}); |
Beta Was this translation helpful? Give feedback.
-
Genius thanks it's work :) |
Beta Was this translation helpful? Give feedback.
Something like: