TGViewer
ботик ботик @botikst · 22 subscribers
Post #51 121
Показатель сердец
import { world, system, Player } from "@minecraft/server";

const previousHearts = new Map();

function her() {
const players = world.getPlayers();

for (const player of players) {
const health = player.getComponent('health').currentValue;
const currentHearts = health / 2;
const playerId = player.id;
const prevHearts = previousHearts.get(playerId) || currentHearts;
player.runCommandAsync(`title @s actionbar ❤ ${currentHearts.toFixed(1)}`);

if (prevHearts > 6.0 && currentHearts <= 6.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§cВнимание! Жизней становится меньше (6.0 сердец)"}]}`);
}
else if (prevHearts > 3.0 && currentHearts <= 3.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§4Тревога! Сердец осталось мало (3.0 сердца)"}]}`);
}
else if (prevHearts > 1.0 && currentHearts <= 1.0) {
player.runCommandAsync(`tellraw @s {"rawtext":[{"text":"§4§lКРИТИЧЕСКИ! Осталось всего 1.0 сердце!"}]}`);
}

previousHearts.set(playerId, currentHearts);
}
}

system.runInterval(her);
More from @botikst
  1. Sep 6, 2026пример WebSocket10
  2. Sep 6, 2026Файл скрипт WebSocket10
  3. Sep 6, 2026файл apk termux
  4. Sep 6, 2026Скрипт WebSocket10 const TelegramBot = require('node-telegram-bot-api'); const WebSocket =…
  5. Sep 6, 2026Команды termux: termux-setup-storage pkg update && pkg upgrade -y pkg install nodejs-lts n…
  6. Jul 26, 2026Пример «Импульс»
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →