OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: OFPWhizz on 12 Mar 2007, 20:35:16
-
Hello.
Is there a way to set up a dialog so that the user has to press a button before it closes down (i.e they cant use escape to quit the dialog)?
-
As far as I know there is nothing to stop the player from using escape to close a dialog. What might work is using a variable to check if the player closed the dialog with the appropriate button. How to incorporate this into your script/mission?
I'll describe one way how to do this, there are much more options. Make a file called "init.sqs" and put it in the mission folder (found under your username/missions). There write the following: dialogclosed=false;
Then the only thing you need to check after opening up the dialog for the player is if he has exited the dialog, if yes, check if the variable is set to true (you can set it to true on the activation line which gets activated after a players presses a button), if not - open up the dialog again.
It has been a while since my last usage of dialogs, I'm about 95% sure that something like this will work. It's just that I don't know how everything has to be set and done. If you need more help, just ask.
-
Method 1: Keep a script running in the background checking the visibility of any control present in your dialog
?(!ctrlVisible 1000): relaunch your dialog here
Method 2 (not tested): Using new displaySetEventHandler ArmA function.
First you need a handler to your dialog display, lets suppose you give 900 to your dialog idd (idd = 900;). And then you assign a script to the "KeyDown" handler.
_display = findDisplay 900
_display displaySetEventHandler ["KeyDown", "yourfunc.sqs"]
I suppose (not tested) that provided script for the "KeyDown" event gets the key pressed into its _this array, so you need to check for a 1 there. 1 = ESC.
To check the behaviour of that function you may try:
;yourfunc.sqs
hint format["KeyDown triggered, _this=%1", _this]
exit
-
Thanks guys thats very helpful :)