#How do I make mobs around me execute the /damage command?
1 messages ยท Page 1 of 1 (latest)
@upbeat crest u want it with command or with script?
Script
@patent olive
system.runInterval(() => {
world.getPlayers().forEach((player) => {
if (lib.scoreboard.get(player, "black_leg_spin") >= 4 && lib.scoreboard.get(player, "black_leg_spin") <= 24) {
player.runCommandAsync(`damage @e[r=2.5] ${(lib.score(player, "dmg")) + 3} entity_attack entity "${player.nameTag}"`)
}
});
}, 2);
So here it is ๐?
It turns out that the damage is also given to the player
How to solve?
What i understand is the player get the damage to right?
When the player has a "black_leg_spin" score between 4 and 24, he executes the /damage command
I don't want the player executing the command to receive the damage
system.runInterval(() => {
world.getPlayers().forEach((player) => {
if (lib.scoreboard.get(player, "black_leg_spin") >= 4 && lib.scoreboard.get(player, "black_leg_spin") <= 24) {
player.runCommandAsync(`damage @e[r=2.5,type=!player] ${(lib.score(player, "dmg")) + 3} entity_attack entity "${player.nameTag}"`)
}
});
}, 2);
Try it
This is should work but there's some things bad like he can give a damage to another players @upbeat crest
But you can solve it with give the player a tag with hes name and check if the player has the name if the same same don't give him a damge and if have another name give him the damage
I want it to cause damage to other players
Ok wait give me a min
I don't want the player executing the command to take damage
Try it @upbeat crest
system.runInterval(() => {
world.getPlayers().forEach((player) => {
player.addTag(player.name);
if (lib.scoreboard.get(player, "black_leg_spin") >= 4 && lib.scoreboard.get(player, "black_leg_spin") <= 24) {
player.runCommandAsync(`damage @e[r=2.5,tag=!${player.name}] ${(lib.score(player, "dmg")) + 3} entity_attack entity "${player.nameTag}"`)
}
});
}, 2);```
But then, I'll have to make another script that makes the tag have the player's name
I have an idea
if (lib.scoreboard.get(player, "black_leg_spin") >= 4 && lib.scoreboard.get(player, "black_leg_spin") <= 24) {
player.runCommandAsync(`damage @e[r=2.5,name=!${player.name}] ${(lib.score(player, "dmg")) + 3} entity_attack entity "${player.nameTag}"`)
: ) i already make that's
I'll try
Look at the first i add the tag to the player
player.addTag(player.name);```
Or u can use the name to
@e[name=!${player.name}]```
why would you do that I mean it's not hard but I don't see a point
[...world.getPlayers()].forEach();
you can run commands from the entity it self and use @s
or use damage method
๐ I don't know, but I apply the ideas that come to me for the first time
isn't that the exact same thing
no
how
well more of why
Like I get doing that changing the it won't effect the orginal but like why dose that matter
applyDamage(amount: number, options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions): boolean
Applies a set of damage to an entity.
Parameters
amount: number
Amount of damage to apply.
options?: EntityApplyDamageByProjectileOptions | EntityApplyDamageOptions = null
Additional options about the source of damage, which may add additional effects or spur additional behaviors on this entity.
Returns boolean - Whether the entity takes any damage. This can return false if the entity is invulnerable or if the damage applied is less than or equal to 0.```
Microsoft docs has some info
This way we can use the native not just a command
I could see it be useful but not really
Bro I can do this, but he wants to do it with command not with script : )
he said script
^^
I saw him put the command in code, and I thought he wanted to continue with that situation
system.runInterval(() => {
world.getPlayers().forEach((player) => {
if (lib.scoreboard.get(player, "black_leg_spin") >= 4 && lib.scoreboard.get(player, "black_leg_spin") <= 24) {
player.dimension.getEntities({location:player.location,maxDistance:2.5}).forEach(e=>{
e.damage(lib.score(player, "dmg") + 3)
})
}
});
}, 2);