get players position at x roundtime #223
-
Hey, me again ;-), first of all: I saw this issue: #3 and tried to use it. demoFile.on('tickend', e => {
let currentRoundTime = demoFile.currentTime - currentRoundStarttime;
if (currentRoundTime > 30.0 && currentRoundTime < 30.025) {
console.log(e, demoFile.currentTime, currentRoundTime);
console.log('NEW ROUND 30 SEC MARK');
for (var i = 0; i < myUserIds.length; i++) {
let ent = demoFile.entities.entities[myUserIds[i]];
console.log(myUserIds[i], ent.position);
let xy = ent.getProp('DT_CSNonLocalPlayerExclusive', 'm_vecOrigin');
console.log('xy', xy);
let pos = {
x: xy.x,
y: xy.y,
z: ent.getProp('DT_CSNonLocalPlayerExclusive', 'm_vecOrigin[2]')
}
console.log(myUserIds[i], pos);
}
}
});
demoFile.gameEvents.on('round_start', e => {
currentRoundStarttime = demoFile.currentTime;
}); The issues I have with this are:
after that I tried the Thank, Raphael Hippe |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi Raphael, A couple of points to note:
With that said, I've fixed your code here - let me know if it works: let checkpointTick = -1;
demoFile.on('tickend', e => {
if (demoFile.currentTick == checkpointTick) {
console.log(e, demoFile.currentTime, demoFile.currentTick);
console.log('NEW ROUND 30 SEC MARK');
for (var i = 0; i < myUserIds.length; i++) {
let ent = demoFile.entities.getByUserId(myUserIds[i]);
console.log(myUserIds[i], ent.position);
}
}
});
demoFile.gameEvents.on('round_start', e => {
let ticksPerSec = demoFile.header.playbackTicks / demoFile.header.playbackTime;
// Calculate the tick that is 30 seconds in the future.
// We do `| 0` to make the number whole (we only ever deal with ticks that are integers).
checkpointTick = (demoFile.currentTick + (30 * ticksPerSec)) | 0;
}); Thanks |
Beta Was this translation helpful? Give feedback.
-
This seems to work. Thank you very much :-) |
Beta Was this translation helpful? Give feedback.
Hi Raphael,
A couple of points to note:
tickend
instead of doing a range check for currentTime. It's more efficient and more accurate.ent.position
on players instead of calculating it manually - you're looking at an old comment. I've edited the comment that you've linked to.With that said, I've fixed your code here - let me know if it works: