Skip to content

Item Dropped #355

Answered by saul
n1c asked this question in Questions
Mar 22, 2022 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Hi @n1c

Does this help?

demoFile.entities.on("change", e => {
  const player = (e.entity as unknown) as Player;
  for (let change of e.changes) {
    if (change.tableName === "m_hMyWeapons") {
      if (!change.oldValue) continue;

      const oldValue = change.oldValue as EntityHandle;
      const newValue = change.newValue as EntityHandle;
      const dropped = oldValue.isValid && !newValue.isValid;

      const weapon = (demoFile.entities.getByHandle(
        dropped ? oldValue : newValue
      ) as unknown) as Weapon | null;

      // The weapon was likely deleted
      if (!weapon) continue;

      console.log(
        `${player.name} ${dropped ? "dropped" : "picked up"} ${
          w…

Replies: 1 comment 2 replies

Comment options

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

@saul
Comment options

Answer selected by n1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants