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

function Banki(player) { //скорборд money
let form = new ModalFormData();
form.title(`Перевод счета с СБ`);

let lplayersList3g16x7p5cn = [];
let lplayerNames3g16x7p5cn = [];
for (const lPlayer3g16x7p5cn of world.getAllPlayers()) {
if (!lPlayer3g16x7p5cn.hasTag('Block')) { //данный тег удаляет игрока с списка (не использовать тег, если нет 2 игрока), если в всех будет тег, то меню не будет открываться из-за отсутствие игроков в списке
lplayerNames3g16x7p5cn.push(lPlayer3g16x7p5cn.name);
lplayersList3g16x7p5cn.push(lPlayer3g16x7p5cn);
}
}

form.dropdown(`Список игроков для перевода`, lplayerNames3g16x7p5cn);
form.textField(`Введите сумму`, `Рублей. . .`);
form.show(player).then(response => {
if (response.canceled) return;

let recipientName = lplayerNames3g16x7p5cn[response.formValues[0]];
let amount = parseInt(response.formValues[1]);

if (isNaN(amount) || amount <= 0) {
player.sendMessage(`§cПожалуйста, введите корректную сумму для перевода.`);
return;
}

player.runCommandAsync(`execute as @s[scores={money=${amount}..}] at @s run scoreboard players add "${recipientName}" money ${amount}`);
player.runCommandAsync(`execute as @s[scores={money=${amount}..}] at @s run tellraw "${recipientName}" {"rawtext":[{"text":"§aВам перевели ${amount}!"}]}`);
player.runCommandAsync(`execute at @s[scores={money=${amount}..}] run scoreboard players remove @s money ${amount}`);
player.runCommandAsync(`execute as @s[scores={money=${amount}..}] at @s run tellraw @s {"rawtext":[{"text":"§aВы перевели ${recipientName} ${amount}."}]}`);
player.runCommandAsync(`execute as @s[scores={money=!${amount}..}] at @s run tellraw @s {"rawtext":[{"text":"§cУ вас недостаточно средств"}]}`);
});
}

world.beforeEvents.itemUse.subscribe((eventData) => { //с помощью предмета
if (eventData.itemStack?.typeId === "minecraft:stick") {
let player = eventData.source;
system.run(() => {
banki(player);
});
}
});

system.runInterval(() => { //с помощью тега
for (let player of world.getPlayers()) {
if (player.hasTag("open")) {
system.run(() => {
banki(player);
player.runCommandAsync(`tag @s remove open`); //удаление тега после открытие
});
}
}
}, 20);
  • 🔥 1
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 →