-
Hello! I've been poking around and can't find any event for when an item (weapon/equipment) is dropped? There's a Not sure if there's something else I'm missing? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
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"} ${
weapon.itemName
}`
);
}
}
}); If you want to ignore weapons dropped on death, then you may need to buffer the dropped items in each tick. Then if a player dies in a given tick, just ignore all of their drops for that tick. Let me know if you need any more help. |
Beta Was this translation helpful? Give feedback.
Hi @n1c
Does this help?