Dialog Styles
From SA-MP Wiki
Note |
|
- This page describes the behavior of ShowPlayerDialog and OnDialogResponse.
- For various limitations, visit the Limits page.
- For the response examples, this code will be used:
public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] ) { printf( "playerid = %d, dialogid = YOUR_DIALOGID, response = %d, listitem = %d, inputtext = '%s' (size: %d)", playerid, response, listitem, inputtext, strlen( inputtext ) ); return 1; }
Style 0: DIALOG_STYLE_MSGBOX
Showing:
Note |
|
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_MSGBOX, "Caption", "Info\n\tInfo", "Button 1", "");
Response output:
// pressed the button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = -1, inputtext = '' (size: 0) // pressed ESC (as the second button isn't visible) playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = -1, inputtext = '' (size: 0)
Style 1: DIALOG_STYLE_INPUT
Showing:
Note |
|
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_INPUT, "Caption", "Enter information below:", "Button 1", "Button 2");
Response output:
// wrote "input" and pressed the left button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = -1, inputtext = 'input' (size: 5) // wrote "input" and pressed the right button playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = -1, inputtext = 'input' (size: 5)
Style 2: DIALOG_STYLE_LIST
Showing:
Note |
|
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_LIST, "Caption", "Item 0\n{FFFF00}Item 1\nItem 2", "Button 1", "Button 2");
Response output:
Note |
|
// selected the first list item and pressed the left button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = 0, inputtext = 'Item 0' (size: 6) // selected the second list item and pressed the right button playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = 1, inputtext = 'Item 1' (size: 6)
Style 3: DIALOG_STYLE_PASSWORD
Showing:
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_PASSWORD, "Caption", "Enter private information below:", "Button 1", "Button 2");
Response output:
Note |
|
// wrote "input" and pressed the left button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = -1, inputtext = 'input' (size: 5) // wrote "input" and pressed the right button playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = -1, inputtext = 'input' (size: 5)
Style 4: DIALOG_STYLE_TABLIST
Showing:
Note |
|
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_TABLIST, "Caption", "Deagle\t$5000\t100\n\ {FF0000}Sawnoff\t{33AA33}$5000\t100\n\ Pistol\t$1000\t50", "Button 1", "Button 2");
Response output:
Note |
|
// selected the first list item and pressed the left button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = 0, inputtext = 'Deagle' (size: 6) // selected the second list item and pressed the right button playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = 1, inputtext = 'Sawnoff' (size: 7)
Style 5: DIALOG_STYLE_TABLIST_HEADERS
Showing:
Note |
|
ShowPlayerDialog(playerid, YOUR_DIALOGID, DIALOG_STYLE_TABLIST_HEADERS, "Caption", "Header 1\tHeader 2\tHeader 3\n\ Item 1 Column 1\tItem 1 Column 2\tItem 1 Column 3\n\ {FF0000}Item 2 Column 1\t{33AA33}Item 2 Column 2\tItem 2 Column 3", "Button 1", "Button 2");
Response output:
Note |
|
// selected the first list item and pressed the left button playerid = 0, dialogid = YOUR_DIALOGID, response = 1, listitem = 0, inputtext = 'Item 1 Column 1' (size: 15) // selected the first list item and pressed the right button playerid = 0, dialogid = YOUR_DIALOGID, response = 0, listitem = 1, inputtext = 'Item 2 Column 1' (size: 15)