#view stats
1 messages · Page 1 of 1 (latest)
playerHitEntity after event
i think
or it might be entityHitEntity
something like that
Pass the hitentity and the damaging entity into the function f(player,target)
how would i do that? im new to scripting
f(data.damagingEntity,data.hitEntity)
and In the f function you do f(player,target)
To show the name it’s target.name
data is not defined
const hitentity = data.hitEntity
at:
f(data.damagingEntity,data.hitEntity)
Well data isn’t defined
I don’t know why your defining data inside the function
Just pass the player who damaged the entity and the hitEntity
That const is useless and it won’t work since you didn’t pass the data into the function arg
like this?
function f(damagingEntity, hitEntity) {
new ActionFormData()
.title(`${hitEntity.name}`)
.button("Exit")
.show(damagingEntity)
.then(data => {
switch (data.selection) {
case 0:
damagingEntity.playSound("random.enderchestclose");
break;
}
});
}
world.afterEvents.entityHitEntity.subscribe((data) => {
const hitEntity = data.hitEntity;
const damagingEntity = data.damagingEntity;
if (damagingEntity.typeId === "minecraft:player" && hitEntity.typeId === "minecraft:player") {
f(damagingEntity, hitEntity);
}
});
import { world } from '@minecraft/server'
import { ActionFormData } from '@minecraft/server-ui'
function f(player, target) {
new ActionFormData()
.title(`${target.name}`)
.button("Exit")
.show(player).then(data => {
switch (data.selection) {
case 0:
player.playSound("random.enderchestclose")
break;
}
}
)
};
world.afterEvents.entityHitEntity.subscribe((data) => {
const hitentity = data.hitEntity
const damagingentity = data.damagingEntity
if (damagingentity.typeId === "minecraft:player" && hitentity.typeId === "minecraft:player") {
f(damagingentity, hitentity)
}
})
Yeah
Looks correct at least from my phone
alr