-
Hello, can I have an example on how to print the total kills + deaths for a certain player in the demo. Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments
-
Have you seen this? https://github.com/saul/demofile/blob/master/dist/examples/dumpfile.js#L91-L108 |
Beta Was this translation helpful? Give feedback.
-
https://i.imgur.com/xOPRdVB.png it's printing all kills in the match, what I'm looking for is a simple code for a certain steamid64 need just the total deaths + kills for one player only (at the end of the match) -help- |
Beta Was this translation helpful? Give feedback.
-
Anyone can help me? need a code to print the total kills/deaths for a certain player.. |
Beta Was this translation helpful? Give feedback.
-
Use the code linked and add an if check on the e.attacker or e.userid against the steamid you are looking for. Store deaths and kills in variables. |
Beta Was this translation helpful? Give feedback.
-
@Borlax2 full example here: const demoFile = new demo.DemoFile();
demoFile.on("end", e => {
if (e.error) {
console.error("Error during parsing:", e.error);
}
const player = demoFile.players.find(x => x.steamId === "STEAM_1:0:56382797")!;
console.log(`Player ${player.name} (${player.steamId}) scored ${player.kills}-${player.deaths}`);
});
// Start parsing the buffer now that we've added our event listeners
demoFile.parse(buffer); |
Beta Was this translation helpful? Give feedback.
-
TypeError: Cannot read property 'name' of undefined error in this line: what I'm missing? |
Beta Was this translation helpful? Give feedback.
-
That means the player it can't find a player with that steam ID. Can you post the full source code? It's also possible that that player has disconnected before the time that the demo finished. |
Beta Was this translation helpful? Give feedback.
-
OK the code seems okay - in which case I think either the player disconnected before the demo finished, or that player was never in the game. |
Beta Was this translation helpful? Give feedback.
-
tried to log all players in the same demo, also tried to log "demoFile.players" and it didn't print any steam_ids |
Beta Was this translation helpful? Give feedback.
-
the demo I'm using was downloaded from an Overwatch case. don't know if that would help. |
Beta Was this translation helpful? Give feedback.
-
I believe overwatch cases have steam IDs stripped from them to hide the identity of those involved with the match. |
Beta Was this translation helpful? Give feedback.
-
make sense now, thanks a lot for your time. |
Beta Was this translation helpful? Give feedback.
@Borlax2 full example here: