#Count how many items of a tag?
1 messages · Page 1 of 1 (latest)
function typeIdAmountInContainer(container, hasTag) {
let output = 0;
for (let i = 0; i < container.size; i++) {
const itemStack = container.getItem(i);
if (itemStack?.hasTag !== hasTag) continue;
output += itemStack.amount;
}
return output;
}
system.runInterval(() => {
world.getAllPlayers().forEach(player => {
typeIdAmountInContainer(player.getComponent("inventory").container, "ec:cyberware");
if (typeIdAmountInContainer > 5) {
player.addEffect("wither", 21, { amplifier: 1 })
}
})
}, 20)