ShowPlayerDialog

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 18:51, 5 July 2013
Smithy (Talk | contribs)
(lipschest)
← Previous diff
Revision as of 22:09, 1 February 2014
Connor Mead (Talk | contribs)

Next diff →
Line 60: Line 60:
[[Category:Scripting Functions]] [[Category:Scripting Functions]]
 +
 +[[fr:ShowPlayerDialog]]
[[ru:ShowPlayerDialog]] [[ru:ShowPlayerDialog]]
[[zh:ShowPlayerDialog]] [[zh:ShowPlayerDialog]]

Revision as of 22:09, 1 February 2014



ShowPlayerDialog was added in SA-MP 0.3a This function was added in SA-MP 0.3a and will not work in earlier versions!


Description:

Shows the player a synchronous (only one at a time) dialog box.


Parameters:
(playerid, dialogid, style, caption[], info[], button1[], button2[])
playeridThe ID of the player to show the dialog to.
dialogidAn ID to assign this dialog to, so responses can be processed. Max dialogid is 32767. Using negative values will close any open dialog.
styleThe style of the dialog.
caption[]The title at the top of the dialog. The length of the caption can not exceed more than 64 characters before it starts to cut off.
info[]The text to display in the main dialog. Use \n to start a new line and \t to tabulate.
button1[]The text on the left button.
button2[]The text on the right button. Leave it blank ( "" ) to hide it.


Return Values:

This function does not return any specific values.


// Define the dialog IDs either with an enum:
enum
{
    DIALOG_LOGIN,
    DIALOG_WELCOME,
    DIALOG_WEAPONS
}
 
// Alternatively, the more common method, defines:
#define DIALOG_LOGIN 1
#define DIALOG_WELCOME 2
#define DIALOG_WEAPONS 3
 
// Enums are recommended, as you don't have to keep track of used IDs. However, enums use memory to store the defines, whereas defines are processed in the 'pre-processor' (compiling) stage.
 
// Example for DIALOG_STYLE_MSGBOX:
ShowPlayerDialog(playerid, DIALOG_WELCOME, DIALOG_STYLE_MSGBOX, "Notice", "You connected to the server", "Close", "");
 
// Example for DIALOG_STYLE_INPUT:
ShowPlayerDialog(playerid,DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", "Enter your password below:", "Login", "Cancel");
 
// Example for DIALOG_STYLE_LIST:
ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons", "AK47\nM4\nSniper Rifle", "Option 1", "Option 2");
 
//example for DIALOG_STYLE_PASSWORD
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", "Enter your password below:", "Login", "Cancel");
Image:32px-Ambox_warning_orange.png

Note

It is recommended to use enumerations (see above) or definitions (#define) to determine which IDs dialogs have, to avoid confusion in the future. You should never use literal numbers for IDs - it gets confusing.


Tips

Image:Light_bulb_icon.png

  • Use color embedding for multiple colors in the text.
  • Using -1 as dialogid closes all dialogs currently shown on the client's screen.


Related Functions

The following functions may be useful, as they are related to this function in one way or another.


Related Callbacks

The following callbacks might be useful, as they're related to this function in one way or another.

In other languages