Knight docs
EN ID
GitHub

Dialogs & TextDraws

Interactive dialogs and on-screen text.

Dialogs

Dialog styles: 0 message box, 1 input, 2 list, 3 password, 4 tab list, 5 tab list headers.

knight
let MENU = 200;

player::command("/menu") {
    ShowPlayerDialog(playerid, MENU, 2, "Main menu",
        "Teleport\nHeal\nGive money", "Select", "Close");
};

dialog::response(int playerid, int id, bool accepted, string input, int listitem) {
    if (id != MENU) { return; }
    if (!accepted) {
        SendClientMessage(playerid, "Menu closed.");
        return;
    }
    if (listitem == 0) { SetPlayerPos(playerid, 1958.4, 1343.2, 15.4); }
    if (listitem == 1) { SetPlayerHealth(playerid, 100.0); }
    if (listitem == 2) { GivePlayerMoney(playerid, 500); }
};
Note
HidePlayerDialog(playerid) closes the current dialog from the server.

TextDraws

knight
let TD = 0;

system::start() {
    // TextDrawCreate(id, x, y, text)
    TextDrawCreate(TD, 320.0, 20.0, "Welcome to Knight");
    TextDrawLetterSize(TD, 0.4, 1.6);
    TextDrawColor(TD, 0xFFFFFFFF);
    TextDrawSetOutline(TD, 1);
    TextDrawSetProportional(TD, true);
};

player::spawn(int playerid) {
    TextDrawShowForPlayer(playerid, TD);
};

player::command("/hidetd") {
    TextDrawHideForPlayer(playerid, TD);
};

Clickable textdraws

knight
TextDrawSetSelectable(TD, true);
SelectTextDraw(playerid, 0xFF0000FF);

textdraw::click(int playerid, int textdrawid) {
    if (textdrawid == TD) {
        SendClientMessage(playerid, "You clicked it!");
        SelectTextDraw(playerid, 0);   // 0 disables selection
    }
};
Tip
Selection uses SelectTextDraw(playerid, colour) to enable and SelectTextDraw(playerid, 0) to disable. A click id of 65535 means the player cancelled.