Skip to content

Buy / Economy events #349

Answered by saul
n1c asked this question in Questions
Feb 26, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Take a look at the purchases example. Specifically the bit you need is:

demoFile.entities.on("create", e => {
  const weapon = e.entity;
  if (!(weapon instanceof Weapon)) return;

  const owner = weapon.owner;
  if (!owner) return;

  // Skip over weapons that are given and not bought
  if (
    weapon.serverClass.name === "CKnife" ||
    weapon.serverClass.name === "CC4" ||
    (owner.teamNumber === 2 && weapon.serverClass.name === "CWeaponGlock") ||
    (owner.teamNumber === 3 && weapon.serverClass.name === "CWeaponHKP2000")
  )
    return;

  console.log(
    `'${owner.name}' just bought a '${weapon.itemName}' (${weapon.quality})`
  );
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@n1c
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