#view stats

1 messages · Page 1 of 1 (latest)

sage mauve
#

i need a script where if you hit someone with a certain tag itll cancel the hit and open up a simple form just displaying there name for the title

#

^

drowsy rune
#

playerHitEntity after event

#

i think

#

or it might be entityHitEntity

#

something like that

sage mauve
#

data is not defined

#

const hitentity = data.hitEntity

f(damagingentity)

#

alr

#

ok

jade maple
#

Pass the hitentity and the damaging entity into the function f(player,target)

sage mauve
jade maple
#

f(data.damagingEntity,data.hitEntity)

#

and In the f function you do f(player,target)

sage mauve
#

at:
f(data.damagingEntity,data.hitEntity)

jade maple
#

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

sage mauve
#

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);
    }
});
jade maple
#
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

sage mauve
#

alr

#

ty

jade maple
#

Looks correct at least from my phone

sage mauve
#

alr