Liamsmith 1 Posted April 8, 2018 Hi i was wondering where i could find an holster and ear plug script for Eden editor. I tried to have a look around for one but i couldn't really find one that i would like. Sorry for asking so many questions new to scripting and mission file editing. For the ear plug script i would like it to be shift o to insert and remove the ear plugs. Something similar to this - https://pastebin.com/kYMtZ1MP For the holster i would like it so shift h or something similar would put your gun on your back and pull it out. 1 Share this post Link to post Share on other sites
Liamsmith 1 Posted April 9, 2018 Thank you however say if i wanted to have shift O to put in the ear phones. How would that be done? Share this post Link to post Share on other sites
mrcurry 496 Posted April 9, 2018 findDisplay 46 displayAddEventHandler [ "KeyDown", { params ["_keyCode", "_shift"]; //Add another if for each key you want recognised. If(_shift && keyname _keyCode == "o") then { //Do stuff }; } ]; 2 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted April 9, 2018 Spoiler 5 hours ago, HazJ said: Thanks HazJ ! Share this post Link to post Share on other sites
Liamsmith 1 Posted April 11, 2018 On 09/04/2018 at 9:10 AM, mrcurry said: findDisplay 46 displayAddEventHandler [ "KeyDown", { params ["_keyCode", "_shift"]; //Add another if for each key you want recognised. If(_shift && keyname _keyCode == "o") then { //Do stuff }; } ]; Could you give me a bit more info. Sort of confused with it. Mainly with checking _shift and _key code and adding another if. Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted April 11, 2018 Hello there Liamsmith ! Check this: https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onKeyDown https://community.bistudio.com/wiki/DIK_KeyCodes Share this post Link to post Share on other sites
Liamsmith 1 Posted April 12, 2018 11 hours ago, GEORGE FLOROS GR said: Hello there Liamsmith ! Check this: https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onKeyDown https://community.bistudio.com/wiki/DIK_KeyCodes I`ve had a look but it still confuses me. I dont understand the variables. I dont get the _shift and _key code. Share this post Link to post Share on other sites
mrcurry 496 Posted April 12, 2018 3 hours ago, Liamsmith said: I`ve had a look but it still confuses me. I dont understand the variables. I dont get the _shift and _key code. They are passed by the eventhandler into the code automatically. For the keyDown event the following parameters are passed to the code in the magic variable _this: _this select 0 : Keycode - The key's keyboard code or DIK code. Essentially the digital representation for the key you pressed. _this select 1 : Shift - State of the shift button as a boolean (true/false). Holding shift while pressing a key will make this return true. _this select 2 : Ctrl - Same as Shift but for Ctrl button. _this select 3 : Alt - Same as Shift but for Alt button. To extract these I use the params command which parses _this into localized variables ready for use. params ["_key", "_shift", "_ctrl", "_alt"]; which is the same as private _key = _this select 0; private _shift = _this select 1; private _ctrl = _this select 2; private _alt = _this select 3; A more extended example: findDisplay 46 displayAddEventHandler [ "KeyDown", { params ["_keyCode", "_shift", "_ctrl", "_alt"]; If(keyname _keyCode == "y") then { //Y is pressed and doesn't care about shift ctrl and alt states. }; If(_shift && keyname _keyCode == "i") then { //Shift + I }; If(!_alt && keyname _keyCode == "o") then { //O is pressed and Alt is not }; If(ctrl && _shift && keyname _keyCode == "p") then { //Ctrl + Shift + P }; If(!ctrl && !_shift && !_alt && keyname _keyCode == "p") then { //P is pressed and none of ctrl shift and alt are pressed. }; } ]; 1 Share this post Link to post Share on other sites