#How to runCommandAsync constantly with a delay of 50 ticks in a .js file?

1 messages · Page 1 of 1 (latest)

dusky jasper
#

How to run something like this every 2 seconds (40 ticks) without chat message needed: js import { world } from "@minecraft/server"; world.events.beforeChat.subscribe((h)=> { if (h.message == "-help") { h.cancel = true; h.sender.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§r§fHelp:§7\n-help\n-profile [name]\n-rewardgold §8[Gold+]§7\n-rewardiron §8[Iron+]§7\n-say [message] §8[Diamond+]§7\n-socials"}]}`) h.sender.runCommandAsync(`playsound crossbow.loading.end @s`) } })

#

Please help me

grizzled stratus
#
system.runInterval(() => {
  //code
}, 40)```
dusky jasper
#
import {
    world
} from "@minecraft/server";
system.runInterval(() => {
    runCommandAsync(`tellraw @a {"rawtext":[{"text":"§r§fHelp:§7\n-help\n-profile [name]\n-rewardgold §8[Gold+]§7\n-rewardiron §8[Iron+]§7\n-say [message] §8[Diamond+]§7\n-socials"}]}`)
    runCommandAsync(`playsound crossbow.loading.end @a`)
}, 40) ```
#

Like this @grizzled stratus ?

grizzled stratus
#

Yes, but import system too;

dusky jasper
#
import {
    world,
    system
} from "@minecraft/server";
system.runInterval(() => {
    runCommandAsync(`tellraw @a {"rawtext":[{"text":"§r§fHelp:§7\n-help\n-profile [name]\n-rewardgold §8[Gold+]§7\n-rewardiron §8[Iron+]§7\n-say [message] §8[Diamond+]§7\n-socials"}]}`)
    runCommandAsync(`playsound crossbow.loading.end @a`)
}, 40) ```
#

Then I don't need to do anything and it automatically gets executed in my world?

#

@grizzled stratus

#

?

#

Is that right?

#

Uhm..

grizzled stratus
#

Yes, that's right.