Skip to content

How to get a player's position on a specific time in a round ? #311

Answered by saul
Dastaan2k asked this question in Questions
Discussion options

You must be logged in to vote

Try this:

let logEventAtTime: number | null = null;
demoFile.gameEvents.on("round_start", e => {
  if (demoFile.gameRules.roundsPlayed === 0) {
    // When rounds played is zero, this is the first round.
    // This can happen multiple times in the same demo when the game restarts.
    console.log("Game restarted");
  } else if (demoFile.gameRules.roundsPlayed === 2) {
    // If 2 rounds have been played, we're starting round 3 now
    logEventAtTime = demoFile.currentTime + 50;
  }
});

demoFile.on("tickend", () => {
  if (logEventAtTime != null && logEventAtTime < demoFile.currentTime) {
    logEventAtTime = null;

    const player = demoFile.entities.getByUserId(17);
    console.log(

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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