-
Say I want to get a player's position on 50 seconds after 3 round starts, how can I get that ? I am able to get player's position on specific events like player_death etc. but how can I get player's position on any general event like the one I asked for above. Thankyou in advance for answering. |
Beta Was this translation helpful? Give feedback.
Answered by
saul
Feb 27, 2022
Replies: 1 comment
-
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(
`At 50 secs after round 2. ${player?.name} ${player?.userId} is at`,
player?.position
);
}
}); Example output:
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
saul
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try this: