Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
manlikeg

Disable ESC button in dialog

Recommended Posts

So I made a dialog for a respawn, and called the dialog on respawn. How do i make it so the player cannot press the esc button to close the dialog?

Share this post


Link to post
Share on other sites

Copied from one of my projects.

escKeyEH = _display displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];

The isServer check was for when I was testing locally. Change _display to:

(findDisplay 46)

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites
1 minute ago, HazJ said:

Copied from one of my projects.


escKeyEH = _display displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];

The isServer check was for when I was testing locally.

thanks so much man

Share this post


Link to post
Share on other sites

I just edited that post. Read the last part.

  • Like 1

Share this post


Link to post
Share on other sites
15 minutes ago, HazJ said:

I just edited that post. Read the last part.

createDialog "respawn";
escKeyEH = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];

 

it isn't working what am i doing wrong

Share this post


Link to post
Share on other sites

Oh... Sorry. I misunderstood. I thought you meant the game's Esc menu. For your custom respawn. Do this:

// IDD set in your dialog
escKeyEH = (findDisplay IDD) displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];
// Or if you use uiNamespace:
escKeyEH = (uiNamespace getVariable "blah") displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];
class dlg_spawnSelection
{
	idd = 53101;
	movingEnable = 1;
	onLoad = "uiNamespace setVariable [""disp_spawnSelection"", (_this select 0)];";
	onUnload = "uiNamespace setVariable [""disp_spawnSelection"", nil];";
	class controls
	{

Example of mine.

  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, HazJ said:

Oh... Sorry. I misunderstood. I thought you meant the game's Esc menu. For your custom respawn. Do this:


// IDD set in your dialog
escKeyEH = (findDisplay IDD) displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];
// Or if you use uiNamespace:
escKeyEH = (uiNamespace getVariable "blah") displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];

class dlg_spawnSelection
{
	idd = 53101;
	movingEnable = 1;
	onLoad = "uiNamespace setVariable [""disp_spawnSelection"", (_this select 0)];";
	onUnload = "uiNamespace setVariable [""disp_spawnSelection"", nil];";
	class controls
	{

Example of mine.

do i run that in init?

Share this post


Link to post
Share on other sites

No. You can have it in the onLoad inside the dialog file or have it in an SQF file which is executed when you open the dialog.

// Dialog file way:

onLoad = "escKeyEH = (findDisplay IDD) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1) && (!isServer)) then {true} else {false};""];";
// I don't know what your IDD is so you'll have to change that yourself

// SQF file way:

waitUntil {(!isNull (findDisplay IDD))};

escKeyEH = (findDisplay IDD) displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];
// Replace "IDD" with your dialog IDD, obviously

 

  • Thanks 1

Share this post


Link to post
Share on other sites
On 02/11/2017 at 10:32 PM, HazJ said:

No. You can have it in the onLoad inside the dialog file or have it in an SQF file which is executed when you open the dialog.

// Dialog file way:


onLoad = "escKeyEH = (findDisplay IDD) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1) && (!isServer)) then {true} else {false};""];";
// I don't know what your IDD is so you'll have to change that yourself

// SQF file way:


waitUntil {(!isNull (findDisplay IDD))};

escKeyEH = (findDisplay IDD) displayAddEventHandler ["KeyDown", "if (((_this select 1) == 1) && (!isServer)) then {true} else {false};"];
// Replace "IDD" with your dialog IDD, obviously

it's really annoying me now :don11: 

 

any chance you can upload your mission file with it on might help :P

Share this post


Link to post
Share on other sites

Uh... Try:

onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1) && (!isServer)) then {true} else {false};""];";

EDIT: You won't see any effect if you are testing locally (in SP Editor) or MP editor for that matter since you are the server. Here:

onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {false};""];";

I just noticed, it should be false anyway. Sorry, my bad lol. Didn't notice in mine as when I was making this, I had that line commentted out. :D

Share this post


Link to post
Share on other sites
5 minutes ago, HazJ said:

Uh... Try:


onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1) && (!isServer)) then {true} else {false};""];";

EDIT: You won't see any effect if you are testing locally (in SP Editor) or MP editor for that matter since you are the server. Here:


onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {false};""];";

I just noticed, it should be false anyway. Sorry, my bad lol. Didn't notice in mine as when I was making this, I had that line commentted out. :D

still closes xD, just replaced the new code with the old one same thing D:

Share this post


Link to post
Share on other sites

Let me test quickly. Will update in 2 minutes, stand by.

  • Thanks 1

Share this post


Link to post
Share on other sites

Sorry. I confused myself again. It should of been true lol. Damn! Sorry for all the confusion haha.

onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {true};""];";

EDIT: If you accidently open this in editor and can't close it. Press "Left Shift + NumPad -" and type the following (just press the letters - no input box is shown):

ENDMISSION

(all together, you have to do it quick though)

  • Like 2

Share this post


Link to post
Share on other sites
1 minute ago, HazJ said:

Sorry. I confused myself again. It should of been true lol. Damn! Sorry for all the confusion haha.


onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {true};""];";

 

no worries man! that works perfectly thanks

Share this post


Link to post
Share on other sites

Cool, glad it's working. I just edited it again as you posted so yeah, read the last bit. (:

  • Thanks 1

Share this post


Link to post
Share on other sites
6 minutes ago, HazJ said:

Cool, glad it's working. I just edited it again as you posted so yeah, read the last bit. (:

    onLoad = "_this execVM 'scripts\_teleport\_menu.sqf'"
    onLoad = "escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {true};""];";

 

sorry to annoy you again lol, to use this with another dialog i have am i able to merge these 2 scripts together as it doesnt work if i leave it like that

Share this post


Link to post
Share on other sites
onLoad = "_this execVM ""scripts\_teleport\_menu.sqf""; escKeyEH = (_this select 0) displayAddEventHandler [""KeyDown"", ""if (((_this select 1) == 1)) then {true};""];";

 

  • Thanks 2

Share this post


Link to post
Share on other sites

×