-
I am trying to get the entity on a detonate event using the I am running the following code, which results in grenade being undefined for the events mentioned above. demoFile.gameEvents.on('***_detonate', e => {
let thrower = demoFile.entities.getByUserId(e.userid);
let grenade = demoFile.entities.entities[e.entityid];
if (thrower && grenade) {
let throwerPosition = thrower.position;
let grenadePostiion = grenade.position;
console.log('%s threw a grenade from position [%s,%s,%s] to position [%s,%s,%s]', thrower.name, throwerPosition.x, throwerPosition.y, throwerPosition.z, grenadePostiion.x, grenadePostiion.y, grenadePostiion.z);
}
}); |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I think what is most likely happening is that the grenade is being immediately removed from the world on detonation, instead of at the next tick. I could fix this in the library by moving any entity deletions until after the events have been fired. In the meantime, you’re best off listening for grenade projectile ‘remove’ events (on demofile.entities). Look for, CDecoyProjectile, for example, in the netprops.txt file in this repository. |
Beta Was this translation helpful? Give feedback.
-
Hey, Cheers |
Beta Was this translation helpful? Give feedback.
-
@RaphaelHippe have you updated to the latest version of the library? |
Beta Was this translation helpful? Give feedback.
-
Yea that was it. Sorry my bad. |
Beta Was this translation helpful? Give feedback.
I think what is most likely happening is that the grenade is being immediately removed from the world on detonation, instead of at the next tick. I could fix this in the library by moving any entity deletions until after the events have been fired.
In the meantime, you’re best off listening for grenade projectile ‘remove’ events (on demofile.entities). Look for, CDecoyProjectile, for example, in the netprops.txt file in this repository.