SA:MP Dialogs - Create dialogs using @dialog
decorator and show them to players. A replacement ShowPlayerDialog
and OnDialogResponse
containing even more callbacks and functions to manipulate dialogs.
- Start by declaring a dialog.
@dialog( .type = MESSAGE_BOX, .args = {"", "Hi", "Hello!", "OK", "NO"} ) HiDialog(playerid);
- Show the dialog to a player.
@command(.type = SLASH_COMMAND) dialogtest(playerid, params[])
{
ShowDialogForPlayer(playerid, "HiDialog");
return 1;
}
Dialog arguments, they go like this:
event
- event which gets called when a player responds to dialog.title
- title of a dialog box.message
- a message, a list or a tablist, depends on a.type
.response1
- "false
" responseresponse2
- "true
" response
- Dialog styles are now dialog types.
@dialog( .type = MESSAGE_BOX, .args = {"", "Hi", "Hello!", "OK", "NO"} ) HiDialog(playerid);
So, instead of just MESSAGE_BOX
, you can use following types:
MESSAGE_BOX
forDIALOG_STYLE_MSGBOX
INPUT_BOX
forDIALOG_STYLE_INPUT
LIST
forDIALOG_STYLE_LIST
PASSWORD_INPUT
forDIALOG_STYLE_PASSWORD
TABLIST
forDIALOG_STYLE_TABLIST
TABLIST_HEADERS
forDIALOG_STYLE_TABLIST_HEADERS
- Called when a player receives the certain dialog.
public OnPlayerDialogReceived(playerid, dialog[])
{
SendClientMessage(playerid, -1, "You received dialog '%s'", dialog);
return 1;
}
- You can hide a dialog, when you do that, this callback gets called.
public OnPlayerDialogHide(playerid, dialog[])
{
SendClientMessage(playerid, -1, "'%s' hidden.", dialog);
return 1;
}
- This is simply a replacement for
OnDialogResponse
.
public OnPlayerDialogResponse(playerid, dialog[], response, listitem, inputtext[])
{
SendClientMessage(playerid, -1,
"You responded to dialog '%s', response: %i, listitem: %i, inputtext: %i",
dialog, response, listitem, inputtext);
return 1;
}
- Show a dialog for player.
- Get a style (type) of a dialog. Returns
-1
if the dialog does not exist. Returns values such asDIALOG_STYLE_MSGBOX
.
new style = GetDialogStyle("HiDialog");
- Hide a shown dialog.
HideDialogForPlayer(playerid);
- Get player's shown dialog. If there is no dialog shown, function will return
0
. Returns a name of a dialog.
GetPlayerDialog(playerid);
- Read more here.