#How to runCommandAsync constantly with a delay of 50 ticks in a .js file?
1 messages · Page 1 of 1 (latest)
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
system.runInterval(() => {
//code
}, 40)```
Is it repeating it?
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 ?
Yes, but import system too;
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..
Yes, that's right.
