Jump to content
  • 0

AH Event Handler Setup


Darth_Rogue

Question

Hey, Awol, I'm trying to understand how you have the displayAddEventHandler checks working in the security_checks.h file. I assume that keyDown = "_this call EPOCH_KeyDown;" is an example of an allowed KeyDown command. What would be the proper syntax for adding a second command to that list? Or is it even possible to do so? Specifically, I'm trying to get the earplugs script working with the stock AH but it's being blocked for non admins since it uses the regular KeyDown function. 

Also, will there be any tutorials coming on the advanced setup of the security options?

 

This should probably be moved to Server Install Help.  Sorry.... brain fart.....

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

In this case the code "_this call EPOCH_KeyDown;" needs to stay for proper functionality of the Epoch mod functions. Should you want to call another function on any of these event handlers you can simply add your code to the beginning of the existing code.

For example to run your own code on the keyDown EH it would look something like this:

keyDown = "_this call YOUR_customKeyDown; _this call EPOCH_KeyDown"

With YOUR_customKeyDown function being defined in your mission files init.sqf so that clients have the function. The EAH will then override the default event handlers after the player logs in.

 

There will be much more documentation going towards 0.4 and should you have any other questions just ask.

Edited by vbawol
Updated order of code to allow blocking key presses correctly
Link to comment
Share on other sites

  • 0

Ok but what about the stock Arma "KeyDown" function?

 

Excerpt from earplugs.sqf:

if(EarPlugsOn) then 
{ 
	Press_F3 = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 61) then {call ToggleEarPlugs;};"];
};

So you would just make the keyDown EH setting look like this?

keyDown = "KeyDown; _this call EPOCH_KeyDown"
Link to comment
Share on other sites

  • 0

Now that I think more about this check KeyDown and the fact that your custom code may also need to pass true to the handler to prevent keypresses maybe better solution could be:

keyDown = "if (_this call EPOCH_KeyDown) then {true} else {_this call YOUR_customKeyDown}"

This would allow EPOCH_KeyDown to return true and still block keypress and execution of your custom code. If they key is not blocked by EPOCH_KeyDown your custom code will run and could also pass true to prevent the keypress.

Link to comment
Share on other sites

  • 0

 

Ok but what about the stock Arma "KeyDown" function?

 

Excerpt from earplugs.sqf:

if(EarPlugsOn) then 
{ 
	Press_F3 = (findDisplay 46) displayAddEventHandler ["KeyDown","if ((_this select 1) == 61) then {call ToggleEarPlugs;};"];
};

...

 

This should work and retain EPOCH_KeyDown's ability to block key presses while calling ToggleEarPlugs if you press the key.

keyDown = "if ((_this select 1) == 61) then {call ToggleEarPlugs;}; _this call EPOCH_KeyDown"
Link to comment
Share on other sites

  • 0

Ok I see how it works. Basically it's like BE filters where you are creating an exception for certain lines of code. By default the AH will block a keyDown instruction unless the code contains the code defined in the keyDown exception. That sound about right in a nutshell?

Link to comment
Share on other sites

  • 0

Actually what happens is that you are adding the code to a new Event Handler that the EAH sets to override the default one so what ever code you set here ends up being the code that executes client side for that event handler.

Link to comment
Share on other sites

  • 0

Ok so if you're basically defining a new EH server side then how do we get that change broadcast to clients? Does it do it automatically or does something new have to be added to the mission file? Or am I over thinking it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...