#actionformshow does not have the required privileges?
1 messages · Page 1 of 1 (latest)
Your await is waiting for the ForceOpen function to end its execution, but you need to use await before showing the form to exit from the current tick or put it inside system.run
yes but your ForceOpen function call the menu function
the menu function do a.show without async/await
but show return a promise
why your function async function ForceOpen is defined inside your handler ?
I will give you a new version of your script which should no longer pose a problem
import { world } from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
async function waitForOpen(player, form) {
while (true) {
const res = await form.show(player);
if (res.cancelationReason !== "userBusy") return res;
}
}
function getMenu() {
const a = new ActionFormData();
a.title("ESMP Flags");
a.button("e", "textures/es");
a.button("e", "textures/en");
a.button("e", "textures/pg");
a.button("e", "textures/fra");
a.button("e", "textures/kr");
a.button("e", "textures/al");
return a;
}
world.beforeEvents.chatSend.subscribe(async ({ sender: player, message }) => {
if (message === "Open:menu") {
await waitForOpen(player, getMenu())
}
});
The problem is that you called the ForceOpen function to open the form that you generated with the menu function. But the menu function displayed the form to the user, something that the ForceOpen function also did
maybe
import {system, world} from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";
async function waitForOpen(player, form) {
while (true) {
const res = await form.show(player);
if (res.cancelationReason !== "userBusy") return res;
}
}
function getMenu() {
const a = new ActionFormData();
a.title("ESMP Flags");
a.button("e", "textures/es");
a.button("e", "textures/en");
a.button("e", "textures/pg");
a.button("e", "textures/fra");
a.button("e", "textures/kr");
a.button("e", "textures/al");
return a;
}
world.beforeEvents.chatSend.subscribe(({ sender: player, message }) => {
if (message === "Open:menu") {
system.run(async () => {
await waitForOpen(player, getMenu());
});
}
});
you have no error? Are you sure it's the cancel that doesn't work?