Page tree
Skip to end of metadata
Go to start of metadata



Introduced in

Version:1.31

Description

Description:Creates a Yes / No confirmation dialog on the screen. When either button (Yes / No) is pressed, the box is removed from the screen, and the specified code runs. It is similar to the createMessageBox command, but is simpler and more convenient to use.

Using the alternative syntax, this function can also create a confirmation dialog with only one button. This usage is similar to the warningMessage command, except that it allows you to specify code to run once the button is pressed, and lets you specify the text of the Continue button.

Syntax

Syntax:[text, yescode, nocode, [yes, no], display] call fn_vbs_confirmationDialog
Parameters:
  • text: String - What to show in the message box.
  • yescode: Code - Code to run, if the Yes button is pressed.
  • nocode: Code - Code to run, if the No button / Esc is pressed (optional).
  • [yes, no]: Array - Replace the yes and no with corresponding strings that you want to appear on the buttons (optional, use empty array [] to use default text).
  • display: Display - If a confirmation dialog is already on the screen, pass its Display object using this parameter, to make the new confirmation dialog a child of it (otherwise, a new dialog is created for the confirmation box).
Return Value:Display - Display of newly created confirmation box.

Alternative Syntax

Syntax:[text, okcode, bntext, display] call fn_vbs_confirmationDialog
Parameters:
  • text: String - What to show in the message box.
  • okcode: Code - Code to run when the Continue button is pressed.
  • bntext: String - Text to use for the Continue button.
  • display: Display - If a confirmation dialog is already on the screen, pass its Display object using this parameter, to make the new confirmation dialog a child of it (otherwise, a new dialog is created for the confirmation box).
Return Value:Display - Display of newly created confirmation box.

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Functions A-Z.

Examples

Examples:
_confirm = ["This is a message box!", {yesclicked = true}, {noclicked = true}, ["Yes","No"]] call fn_vbs_confirmationDialog
pauseSimulation true;
["This is a warning message!", {PauseSimulation false}, "Continue"] call fn_vbs_confirmationDialog

Additional Information

See also: createMessageBox, warningMessage
Multiplayer:
Problems:

Notes








Posted on Feb 17, 2011
Kronzky
When assigning values to global variable (as in the first example), make sure that you wait explicitly for the dialog to close, before interpreting the variable. The code below will NOT work, unless it contains the "waitUntil" line:


clicked=-1;
_confirm = ["Click something", {clicked = 1}, {clicked = 0}] call fn_vbs_confirmationDialog;
waitUntil {!dialog}; // This line is crucial!
player sidechat format["[K] %1",clicked];