Skip to content

Dialogs

dev2alert edited this page Feb 4, 2022 · 1 revision

Home ▸ Dialogs

Creating dialog

1 way

Showing the dialog by explicitly specifying the ID:

player.dialog({
    id: 0,
    caption: "Caption",
    info: "Info",
    buttons: ["Ok", "Cancel"],
    style: DialogStyles.MSGBOX
});

2 way

Showing a dialog with a pre-generated ID:

const dialog = new Dialog({
    caption: "Caption",
    info: "Info",
    buttons: ["Ok", "Cancel"],
    style: DialogStyles.MSGBOX
});

// <...>
player.dialog(dialog);
// <...>

Creating response handlers

Before you start creating event handlers for responses from dialogs, you need to initialize their work:

Dialog.response.init();

Creating handler:

Dialog.response(dialog, (player, response) => {
    if(response.response)
        return;
    // <...>
});
Clone this wiki locally