-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Game event buytime_ended triggers only once #370
Comments
I've cross-checked with some of the demos I have locally and I can reproduce this issue. I don't think it's an issue with the parser - some events just don't seem to be recorded correctly in demos. Instead you can add up every player's demoFile.gameEvents.on("round_end", e => {
let tValue = 0;
let ctValue = 0;
for (const player of demoFile.players) {
if (player.teamNumber == TeamNumber.Terrorists) {
tValue += player.freezeTimeEndEquipmentValue;
} else {
ctValue += player.freezeTimeEndEquipmentValue;
}
}
console.log(
`End of round #${demoFile.gameRules.roundsPlayed} in ${demoFile.gameRules.phase}:`
);
console.log(` - Terrorist: \$${tValue}`);
console.log(` - Counter-Terrorist: \$${ctValue}`);
}); Let me know if that doesn't work for you can I'll re-open. |
Thank you @saul for checking and confirming the problem. Unfortunately the I will try to calculate the correct equipment in a different way then. Thanks again for checking and great work on this library 👍 |
Good point! Try this instead: let buyTimeTicks = -1;
demoFile.conVars.on("change", e => {
if (e.name === "mp_buytime") {
const secs = parseInt(e.value);
buyTimeTicks = secs * demoFile.tickRate;
console.log(`Buy time is ${secs} secs (${buyTimeTicks} ticks)`);
}
});
let buyTimeEndTick = -1;
demoFile.on("tickend", e => {
if (buyTimeEndTick < 0 || demoFile.currentTick < buyTimeEndTick) return;
buyTimeEndTick = -1;
// Buy time has ended
let tValue = 0;
let ctValue = 0;
for (const player of demoFile.players) {
if (player.teamNumber == TeamNumber.Terrorists) {
tValue += player.currentEquipmentValue;
} else if (player.teamNumber == TeamNumber.CounterTerrorists) {
ctValue += player.currentEquipmentValue;
}
}
console.log(
`Buy time end round #${demoFile.gameRules.roundsPlayed} in ${demoFile.gameRules.phase}:`
);
console.log(` - Terrorist: \$${tValue}`);
console.log(` - Counter-Terrorist: \$${ctValue}`);
});
demoFile.gameEvents.on("round_start", e => {
if (buyTimeTicks >= 0) buyTimeEndTick = demoFile.currentTick + buyTimeTicks;
}); |
Research
Description
Hi,
I am trying to listen to the
buytime_ended
event to calculate the correct team economy value.It seems though that this event is triggered only once after the first round. For all further rounds it is not triggered.
I was not able to find further documentation on this event nor any other information.
Many thanks in advance.
Code to reproduce
Affected demos
No response
The text was updated successfully, but these errors were encountered: