TGViewer
ботик ботик @botikst · 22 subscribers
Post #31 95
Показатель скорборда
import { world, system } from "@minecraft/server";
import { ActionFormData, ModalFormData } from "@minecraft/server-ui"; //ModalFormData на всякий случай

function prof(player) {
let form = new ActionFormData();
form.title(`меню`);

let money = getScore(player, "Money") || 0; // обработка undefined, также можно создать и 2 3 и т.д

form.body(`Ваш баланс: ${money}`);
form.button("Закрыть");
form.show(player).then((onfulfilled) => {
if (onfulfilled.canceled != true) {
const selection = onfulfilled.selection;
if (selection == 0) {
player.runCommadnAsync(``);
}
}
});
}

function rec(player, objective, min, max) {
if (min >= max) { // Изменено условие выхода из рекурсии
return min;
}
const middle = min + Math.floor((max - min) / 2);
const p1 = world.getPlayers({ name: player.name, scoreOptions: [{ objective: objective, minScore: min, maxScore: middle }] });
if (p1.length > 0) { // Изменено условие поиска
return rec(player, objective, min, middle);
} else {
return rec(player, objective, middle + 1, max); // Добавлено смещение middle
}
}

function getScore(player, objective) {
const p1 = world.getPlayers({ name: player.name, scoreOptions: [{ objective: objective, minScore: -2147483648, maxScore: 2147483647 }] });
if (p1.length === 0) {
return 0;
}
return rec(player, objective, -2147483648, 2147483647);
}


world.beforeEvents.itemUse.subscribe((eventData) => {
if (eventData.itemStack?.typeId === "minecraft:stick") {
let player = eventData.source;
system.run(() => {
prof(player);
});
}
});
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 →