#How does one makes a command that opens a GUI?

12 messages · Page 1 of 1 (latest)

robust cloak
#

i came up with these two scripts
server script:


ServerEvents.commandRegistry(event => {
  const { commands: Commands, arguments: Arguments } = event;

  // /prg
  event.register(
    Commands.literal("prg")
      .executes(ctx => {
        const player = ctx.source.player;


        player.sendData("open_progress_gui", {});

        return 1;
      })
  );
});

client scriptl:

NetworkEvents.dataReceived("open_progress_gui", event => {
  const player = Client.player;
  if (player) {

    Client.openScreen("SimpleProgressScreen");
  }
});

am i overcomplecating it?

sudden sapphireBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

robust cloak
#

any example scripts is fine

#

currently script registrates the command

#

but noting happens

prime talon
#

hello

#

Try using let player = ctx.source.playerOrException instead of const player = ctx.source.player;

#
let player = ctx.source.playerOrException
// instead of 
const player = ctx.source.player;
ocean copperBOT
#

🗒️ Send the code! 🗒️

You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

prime talon
#
ServerEvents.commandRegistry(event => {
  const { commands: Commands, arguments: Arguments } = event;

  // /prg
  event.register(
    Commands.literal("prg")
      .executes(ctx => {
        const player = ctx.source.playerOrException;


        player.sendData("open_progress_gui", {});

        return 1;
      })
  );
});
#

in my custom command this workds i dont know really why but this works

robust cloak