#ui form help

1 messages · Page 1 of 1 (latest)

bleak lynxBOT
#
Debug Result

There are errors in this [code](#1070429658602016768 message):

<repl>.js:13:14 - error TS2345: Argument of type 'Entity' is not assignable to parameter of type 'Player'.
  Type 'Entity' is missing the following properties from type 'Player': name, onScreenDisplay, selectedSlot, getItemCooldown, and 6 more.

13     TPA.show(source).then(({ formValues }) => {
                ~~~~~~
<repl>.js:13:30 - error TS2339: Property 'formValues' does not exist on type 'MessageFormResponse'.

13     TPA.show(source).then(({ formValues }) => {
                                ~~~~~~~~~~
<repl>.js:14:28 - error TS2304: Cannot find name 'result'.

14          const selection = result.selection
                              ~~~~~~
<repl>.js:22:18 - error TS2552: Cannot find name 'player'. Did you mean 'players'?

22     request.show(player).then(result => {
                    ~~~~~~

  <repl>.js:16:11
    16     const players = world.getAllPlayers().map(p => p.name);
                 ~~~~~~~
    'players' is declared here.

next flame
#

@granite coral

granite coral
#

sorry been busy

#

i dont fully understand the debug

granite coral
#
import * as ui from "@minecraft/server-ui";

world.events.beforeItemUse.subscribe(({ source, item }) => {
    if (item.typeId !== "minecraft:stick") return;
    
    const TPA = new ui.MessageFormData();
    TPA.title("TPA");
    TPA.body("please select a request or accept line.\nrequest line to request a tp.\naccept line to accept a tp.")
    TPA.button1("request");
    TPA.button2("accept");

    TPA.show(source).then(({}) => {
         const selection = result.selection
         if (selection === 0) {
    const players = world.getAllPlayers().map(p => p.name);
    const request = new ui.ModalFormData();
    request.title("request");
    request.textField("Player name (CAP sensitive)", "Enter the player name");
    request.slider("Amount to send",10,10000,10,10);

    request.show(source).then(result => {
        const [playerName, amount] = formValues;
        const player = world.getAllPlayers().find(p => p.name === playerName);
      
        if (source) {
            source.runCommandAsync(``);
            source.runCommandAsync(``);
            source.runCommandAsync(``);

        }
    });
}})})```