#Help

1 messages · Page 1 of 1 (latest)

sage dune
#

[Scripting][error]-ReferenceError: Native function [Entity::runCommand] does not have required privileges. at <anonymous> (boussole.js:345)
Image
help

#

[Scripting][error]-ReferenceError: Native function [Entity::runCommand] does not have required privileges. at <anonymous> (boussole.js:345)
Image
help

wild dust
#

hello

#
system.run(() => { you script })```
sage dune
#

case "vol":
if (data.sender.hasTag("Fondateur")) {
data.sender.runCommand("gamemode creative @s");
return;
}
return;

sage dune
shell kernel
#
//beforeEvent (read-only) scope
//originated from: world.beforeEvents[eventName].subscribe()

entity.runCommand() //Privilage error
entity.teleport() //Privilage error

//Exiting beforeEvent scope
system.run(()=>{
    //working
    entity.runCommand()
    entity.teleport()
})

There are multiple ways to exit beforeEvent (read-only) scope. system.run() is one of them.

reef cloak
#

my solution if your code is not within a beforeEvent, Gega's solution if it is

sage dune
#

Thanks you ^^

shell kernel
#

If you're dealing with EarlyExecution privilege in the new 2.0.0-beta you can simply:

import { world } from "@minecraft/server";
//within EarlyExecution scope

world.sendMessage() //Privilage Error
world.getDimension() //Privilage Error
dimension.runCommand() //Privilage Error

//exiting scope
await null;

//your old code below
world.sendMessage() //working
world.getDimension() //working
dimension.runCommand() //working

worldLoad events is the intended way, but await null; is quite compact

shell kernel
dim vapor
shell kernel
#

ok

dim vapor
shadow needle
shell kernel
#

That isn't privilage error. That's ur fault.

shell kernel
shadow needle
#

Ok so that would fix alot of stuff, does that include events inside this event?

shadow needle
dim vapor
shell kernel
#

system.run also technically work

shadow needle
dim vapor
#

but just adding scores dont work at all

shadow needle
#

Yeah my scoreboard database broke

dim vapor
#

imma try and get back to you

shadow needle
#

Ok!

#

I'm curious as I had issues with one of my addons

#

Using scoreboards

dim vapor
shell kernel
dim vapor
# shell kernel What's the code in there
import { world, system } from "@minecraft/server";

export function addScore(target, objective, amount) {
    try {
        target.runCommandAsync(`scoreboard players add @s ${objective} ${amount}`);
    } catch (error) {
        console.error(`Error adding score for ${target.name} in ${objective}: ${error}`);
    }
}


system.runInterval(() => {
      addScore(player, "afktime", 1);
      console.warn("ADD SCORE WORKS")

})
shell kernel
#

use native method bruhh

dim vapor
dim vapor
reef cloak
#

yeah

dim vapor