#when i add effects to the player it doesn't work

1 messages · Page 1 of 1 (latest)

vagrant jacinth
#

when i add effects to the player it doesn't work

tight stirrup
#

the duration is in ticks, not seconds

vagrant jacinth
#

[Scripting][error]-ReferenceError: Native function [Entity::addEffect] does not have required privileges. at <anonymous> (interact_items/sword fighter.js:8)

this is the error

tight stirrup
#

you need to use system.run to take it out of the readonly state

vagrant jacinth
#

?

fathom spire
#

do:

console.warn('')
import { world, system } from "@minecraft/server"

world.beforeEvents.itemUse.subscribe(data => {
    let player = data.source
    const Cooldown = world.scoreboard.getObjective("Cooldown")
    if (data.itemStack.typeId == "anlos_rpg:sword" && player.getTags().includes('fighter') && Cooldown.getScore(player) == 0) {
        system.run(() => {
          player.addEffect('strength', 10, 5)
        }
    }
})
fathom spire
tight stirrup
#

the third argument to addEffect is wrong

vagrant jacinth
#

console.warn('')
import { world, system } from "@minecraft/server"

world.beforeEvents.itemUse.subscribe(data => {
let player = data.source
const Cooldown = world.scoreboard.getObjective("Cooldown")
if (data.itemStack.typeId == "anlos_rpg:sword" && player.getTags().includes('fighter') && Cooldown.getScore(player) == 0) {
system.run(() => {
player.addEffect('strength', 200, 5)
})
}
}
)

tight stirrup
#

5 -> { amplifier: 5 }

vagrant jacinth
#

can you give an example to what i should look like

tight stirrup
vagrant jacinth
#

i have this error [Scripting][error]-TypeError: Native optional type conversion failed. Function argument [2] expected type: EntityEffectOptions | undefined at <anonymous> (interact_items/sword fighter.js:9)

tight stirrup
#

player.addEffect('strength', 200, 5) -> player.addEffect('strength', 200, { amplifier: 5 })

vagrant jacinth
#

thanks

#

it works thanks

#

when i try giveing strength 1 it gives strength 2

fathom spire
vagrant jacinth
#

player.addEffect('strength', 200, { amplifier: 1 })

#

it still gives strength 2

fathom spire
#

hmm

#

use amplifier: 0

vagrant jacinth
#

it worked