#Killing specific entity will give you different points

1 messages · Page 1 of 1 (latest)

dry kiln
#

Like if i kill a zombie, i get a point 1, and if i kill a spider, i get point 2

bronze fiber
#
let low = [ "zombie", "creeper"]

if(entityhurt.includes(low)) return point = 1
#

Use event entityHurt

dry kiln
#

no

bronze fiber
#

Then

dry kiln
#

I want it like this

const entity = {
    "minecraft:zombie": 1,
    "minecraft:skeleton": 2
}

if (victim.includes(entity) && initiator.typeId("minecraft:player")) 
player.runCommandAsync("scoreboard players add @s gold //the point in the entity variable")
bronze fiber
#

Owh

tame totem
#

didnt I send the code already?

#

#1067535608660107284 message

dry kiln
tame totem
#

just projectile

#

but u can change the if statments there

dry kiln
#

Do i remove it?

#

I kind of make it to work on projectiles and other things

tame totem
#

@dry kiln ```js

const entity = {
"minecraft:zombie": 1,
"minecraft:spider": 2,
"minecraft:skeleton": 3
}

world.events.entityHurt.subscribe((data) => {
const {
hurtEntity: victim,
damageSource: {
cause,
damagingEntity: initiator,
damagingProjectile: projectile
}
} = data;

const { current } = victim.getComponent('health')
if (current > 0 || initiator?.typeId !== 'minecraft:player') return;
const scorePoints = entity[victim.typeId] ?? 0
initiator.runCommandAsync(scoreboard players add @s gold ${scorePoints})
switch (cause) {
case 'projectile':
initiator.runCommandAsync('say '+cause)
projectile.runCommandAsync('say '+cause)
break;
case 'entityAttack':
initiator.runCommandAsync('say '+cause)
break;
case 'magic':
initiator.runCommandAsync('say '+cause)
break;
case 'thorns':
initiator.runCommandAsync('say '+cause)
break;
}
})

dry kiln
tame totem
#

do u want it only working in player?

dry kiln
tame totem
#

there

marble beaconBOT
#
No errors

No errors in [code](#1076438191747371049 message)

dry kiln
# tame totem there

Can you tell whats gonna happen and why there projectiles projectile.runCommandAsync

tame totem
#

either remove oif u dont need it or add somethin there.
Both ways works