Skip to content
Discussion options

You must be logged in to vote

This is simply how the weapons are reported in the player_hurt event. If you want to get the actual weapon name, you need to get the attacking player entity, get their active weapon, then get the item name. Something like:

demoFile.gameEvents.on("player_hurt", e => {
  const victim = demoFile.entities.getByUserId(e.userid);
  const attacker = demoFile.entities.getByUserId(e.attacker);
  console.log(
    `${attacker?.name} hit ${victim?.name} [${attacker?.weapon?.itemName}] for ${e.dmg_health} HP`
  );
});

The game does this transformation for you already on player_death, but for some reason they didn't do it for player_hurt.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dclayto1
Comment options

@dclayto1
Comment options

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
Converted from issue

This discussion was converted from issue #282 on April 03, 2021 09:02.