Jump to content
Sign in to follow this  
=Odin=

displaySetEventHandler

Recommended Posts

G'day I have a few questions on the use of displaySetEventHandler

to start I am useing this in the playerinit

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Delays creation of the event handler until everything else is initialized.

sleep 1;

// Creates the event handler that detects "Key Up" events and executes the script as appropriate.

//Recruit Via the "H" Key on keyboard

(findDisplay 46) displaySetEventHandler ["KeyUp", "_nil = _this execVM ""scripts\keyE.sqf"""];

this is the keyE.sqf

Quote[/b] ]// If you want something to be done on

// any key:

// hint "SOME KEY PRESSED!";

switch((_this select 1))do

{

// Reacts to "H" key only

case 35:

{

hint "Recruit!";

nul=[] execVM "scripts\hiremanGR.sqf";

};

};

question 1; Is it possible to assighn another Key to call a seperate Dialog?

eg <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">switch((_this select 1))do

{

// Reacts to "I" key only

case 23:

{

hint "Disband!";

nul=[] execVM "scripts\list.sqf";

};

};

Question 2; are these scripts going to be local to player or Global, if they are global can I make them local?

Thx

Share this post


Link to post
Share on other sites

switch case is a command that checks the input against each case. In this script, it's looking at the key input and only executing the code for that 'case.'

So if you want to add more keys, you can just add new entries to the switch-case.

Quote[/b] ]// If you want something to be done on

// any key:

// hint "SOME KEY PRESSED!";

switch((_this select 1))do

{

// Reacts to "I" key only

case 23:

{

hint "Disband!";

nul=[] execVM "scripts\list.sqf";

};

// Reacts to "H" key only

case 35:

{

hint "Recruit!";

nul=[] execVM "scripts\hiremanGR.sqf";

};

};

These scripts are local to the player as they are only firing on the machine that pressed the key. They will not trigger for all players/clients.

Good luck!

Share this post


Link to post
Share on other sites

Thanx captain, works like a charm, Ta for clearing that and the locality issue, I was worried about duel pop ups like l get useing a radio trigger

Odin

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×