Results 1 to 5 of 5

Thread: script "Taking over" a key?

  1. #1

    script "Taking over" a key?

    I want to try something in a mission and for that I need to disable the CQB sights key. Is there an easy way to make the mission override whatever key the user have bound for CQB sights to instead do nothing?

    ---------- Post added at 10:03 PM ---------- Previous post was at 08:11 PM ----------

    Guess I answered myself on this one:

    Code:
    disableSerialization;
    waitUntil {!isNull (findDisplay 46)};
    (findDisplay 46) displayAddEventHandler ["KeyDown",
    "
    	private['_handled'];
    	_handled = false;
    	_key = _this select 1;
    	if (_key in (actionKeys 'OpticsMode')) then
    	{
    		_handled=true;
    	};
    	_handled;
    "];

  2. #2
    Hmm, could you use that to trap "Sprinting" too? I wanted to force the player to walk and I can do that but they can still sprint just fine (double tap W).

  3. #3
    Probably same thing would work for sprinting if you just guess the key name correctly - worth trying. You could even add a check in the handler's code that returns false if sprinting is enabled and only returns true when it's disabled, so you don't have to create/remove the handler.

  4. #4
    I've had no luck with this. I've figured out that "W" = 17, and the actionKeys for MoveFastForward (sprinting) is 273, but I can't for the life of my trap "MoveFastForward" being active...

    Anyone know how to capture MoveFastForward to disable sprinting or how you capture a x2 keystroke?

  5. #5
    I've had no luck with this. I've figured out that "W" = 17, and the actionKeys for MoveFastForward (sprinting) is 273, but I can't for the life of my trap "MoveFastForward" being active...

    Anyone know how to capture MoveFastForward to disable sprinting or how you capture a x2 keystroke?
    Hmm - if the engine doesn't automatically coalesce the double-tab then the next best thing would be to add a timer in your key handler to detect this. Something like...

    Code:
    wActive=0;
    wPressed={
        wActive=wActive+1;
        sleep 0.5; //exact delay may need some tweaking
        wActive=wActive-1;
    };
    
    
    keyDown={
        private ["_handled"];
        _handled = false;
        //walkbindings is an array of dik-codes for 'walk' action
        if ((_this select 1) in WalkBindings) then {
            _handled = (wActive >0) ;
            [] spawn { call wPressed};
        };
        _handled;
    };
    
    (findDisplay 46) displayAddEventHandler ["KeyDown","this call keyDown"];
    Author of PVPmissionWizard ArmA2FPSAnalyser AddonChecker and ... squint

    Tools homepage

    Crosseyed and Painless - a blog about my ArmA2 developments



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •