From 1863c43c18a9d415dc54b54d0350fbdfeb0e7be0 Mon Sep 17 00:00:00 2001 From: Phoenix <79187578+Phoenix-rat@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:10:47 +0300 Subject: [PATCH 1/2] + Super Duper Broadcast --- src/command/cmds/sdb.ts | 75 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/command/cmds/sdb.ts diff --git a/src/command/cmds/sdb.ts b/src/command/cmds/sdb.ts new file mode 100644 index 00000000..43d0d612 --- /dev/null +++ b/src/command/cmds/sdb.ts @@ -0,0 +1,75 @@ +import { Command } from "../Command"; +import { Base } from "../../core/Base"; +import { Peer } from "../../core/Peer"; +import { ROLE } from "../../Constants"; +import { Variant, TextPacket, PacketTypes } from "growtopia.js"; +import { DialogBuilder } from "../../utils/builders/DialogBuilder"; + +export default class Sdb extends Command { + constructor( + public base: Base, + public peer: Peer, + public text: string, + public args: string[] + ) { + super(base, peer, text, args); + this.opt = { + command: ["sdb"], + description: "Send a global message to everyone via a dialog box", + cooldown: 5, + ratelimit: 1, + category: "`bDev", + usage: "/sdb ", + example: ["/sdb Hello everyone!"], + permission: [ROLE.DEVELOPER] + }; + } + + public async execute(): Promise { + if (!this.args.length) + return this.peer.send(Variant.from("Message is required.")); + + const message = this.args.join(" "); + const senderName = this.peer.name; + const world = this.peer.currentWorld(); + const jammed = world?.data.jammers?.find((v) => v.type === "signal")?.enabled; + + // Dialog box creation + const dialog = new DialogBuilder() + .defaultColor() + .addLabelWithIcon("Super Duper Broadcast", "2480", "big") + .addSpacer("small") + .addSmallText(`\`oMessage from: \`$${senderName}`); + + // If no jammer, show the world name + if (!jammed) { + dialog.addSmallText(`\`oWorld: \`o${this.peer.data.world}`); + } else { + dialog.addSmallText("`4JAMMED`"); + } + + dialog + .addSpacer("small") + .addSmallText(`\`5${message}`) + .addQuickExit() + .endDialog("ok", "Close", ""); + + // Send dialog box and play beep sound to all players + this.peer.every((player) => { + player.send( + Variant.from("OnDialogRequest", dialog.str()), + TextPacket.from( + PacketTypes.ACTION, + "action|play_sfx", + `file|audio/beep.wav`, + `delayMS|0` + ) + ); + }); + + // Confirmation to sender + this.peer.send( + Variant.from("OnConsoleMessage", `\`2Super Duper Broadcast sent to all players.`) + ); + } +} From 0868b31676125179ab9c2ae441fb496ec296d1af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fan=20AYDIN?= <79187578+Phoenix-rat@users.noreply.github.com> Date: Mon, 27 Jan 2025 22:16:22 +0300 Subject: [PATCH 2/2] Update sdb.ts ESLint Update --- src/command/cmds/sdb.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/command/cmds/sdb.ts b/src/command/cmds/sdb.ts index 43d0d612..bb92966e 100644 --- a/src/command/cmds/sdb.ts +++ b/src/command/cmds/sdb.ts @@ -14,14 +14,14 @@ export default class Sdb extends Command { ) { super(base, peer, text, args); this.opt = { - command: ["sdb"], + command: ["sdb"], description: "Send a global message to everyone via a dialog box", - cooldown: 5, - ratelimit: 1, - category: "`bDev", - usage: "/sdb ", - example: ["/sdb Hello everyone!"], - permission: [ROLE.DEVELOPER] + cooldown: 5, + ratelimit: 1, + category: "`bDev", + usage: "/sdb ", + example: ["/sdb Hello everyone!"], + permission: [ROLE.DEVELOPER] }; }