samp.directory
← Tools

Dialog builder

Pick a style, write the title, the text and the buttons, try the dialog as a player would, and copy the code that shows it and handles the answer.

Style

Each line is an item, which {RRGGBB} colours.

Write the ID with

Preview

Click a row to pick it, and a button (or a double click) to answer. The arrows, Enter and Esc work as in the game.

Teleports
Los Santos
San Fierro
Las Venturas
Mount Chiliad
Back
Press a button in the preview to see what OnDialogResponse is given.

Within what the client holds.

Code

Code for

SA-MP and open.mp take this code just as it is: the choice only picks the includes it is compiled with.

Show the dialog

#define DIALOG_TELEPORTS 3

ShowPlayerDialog(playerid, DIALOG_TELEPORTS, DIALOG_STYLE_LIST, "Teleports", "Los Santos\nSan Fierro\nLas Venturas\n{FFFF00}Mount Chiliad\n{AAAAAA}Back", "Go", "Close");

Handle the answer (if you have an OnDialogResponse already, add the if to it)

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if (dialogid == DIALOG_TELEPORTS)
    {
        if (!response)
        {
            // "Close" or Esc
            return 1;
        }
        switch (listitem)
        {
            case 0: // Los Santos
            {
            }
            case 1: // San Fierro
            {
            }
            case 2: // Las Venturas
            {
            }
            case 3: // Mount Chiliad
            {
            }
            case 4: // Back
            {
            }
        }
        return 1;
    }
    return 0;
}
Paste a ShowPlayerDialog to edit it

How SA-MP dialogs work

SA-MP dialog builder: ShowPlayerDialog preview and code | samp.directory