#Why does this run multiple times on players death? Resolved
1 messages · Page 1 of 1 (latest)
system.runTimeout(() => {
world.scoreboard.getObjective('Deaths').addScore(killed, 1);
world.scoreboard.getObjective('Combat').setScore(killed, 0);
killed.removeTag("ffa");
world.scoreboard.getObjective('Kills').addScore(killer, 1);
killer.runCommandAsync('playsound random.orb @s');
world.scoreboard.getObjective('Streak').addScore(killer, 1);
world.scoreboard.getObjective('Combat').setScore(killer, 0);
world.scoreboard.getObjective('Combo').setScore(killer, 0);
// Resetting Streak for killed player
world.scoreboard.getObjective('Streak').setScore(killed, 0);
handleRankUp(killer)
}, 0);
const killerHasTagRDU = killer.hasTag('rdu');
const killedHasTagRDU = killed.hasTag('rdu');
let xpToAdd = calculateXpToAdd(killerRank, killedRank);
if (killerHasTagRDU && killedHasTagRDU) {
// Double the xpToAdd if both have the tag "rdu"
xpToAdd *= 2;
killed.runCommandAsync(`scoreboard players remove @s XP ${xpToAdd}`)
}
const killerHasTagtf = killer.hasTag('tf');
if (killerHasTagtf) {
xpToAdd /= 2;
}
const killerHasTagffa = killer.hasTag('ffa');
if (killerHasTagffa) {
xpToAdd /= 10;
}
if (xpToAdd > 0) {
killer.runCommandAsync(`scoreboard players add @s XP ${xpToAdd}`);
killer.sendMessage(`§c+1 Kill\n§a+Xp ${xpToAdd}`);
}
killer.runCommandAsync('effect @s instant_health 1 255 true');
}
}
});
there is i just dont have nitro so message is to big
world.afterEvents.entityDie.subscribe(function (event) {
if (!(event.deadEntity instanceof Player)) return
const player = event.deadEntity;
// do whatever
});
this part of my code works
thanks tho
probably because your kill event is in the entityHurt
so whenever an entity gets hurt itll run that
Hello guys ! I was wondering if it still works ?
I would to spawn an item when a player dies ^^
because the post is from 2023...
if I had to guess it probably still does, I haven't done anything with minecraft scripting in a while though
just try it, if it does it does, and if it doesn't create a new post asking how to do what you are trying to do
The event should still exist so yea