Jump to content

Recommended Posts

I'm trying to edit the autorun script from [Release] Auto Run Script

I want to set the keys that interrupt auto running to be only Shift, Tab, W, A, S, and D, but it seems that only Shift and WASD work. Any idea why?

 

initPlayerLocal.sqf:


//-------------------------AUTORUN-------------------------------------
if (hasInterface) then{
	waitUntil {!isNull findDisplay 46};
  	(findDisplay 46) displayAddEventHandler ["KeyDown", {
    if (_this select 1 == (actionKeys 'uavView') select 0) then {
		if (isNil "AR_active") then {AR_active = false};
 		if (AR_active) exitWith {AR_active = false};
		if (!isNull objectParent player) exitWith {};
		if (surfaceIsWater (getPos player)) exitWith {};

		_legdamage = player getHit "legs";
		AR_active = true;
		AR_weapon = currentWeapon player;
		AR_animation = switch (true) do {
			case (AR_weapon isEqualTo ""): {"AmovPercMevaSnonWnonDf"};
			case (AR_weapon isEqualTo (handgunWeapon player)): {"AmovPercMevaSlowWpstDf"};
			case (AR_weapon isEqualTo (primaryWeapon player)): {"AmovPercMevaSlowWrflDf"};
			case (AR_weapon isEqualTo (secondaryWeapon player)): {"AmovPercMevaSlowWlnrDf"};
		};
		player addEventHandler ["AnimDone", {
			if ((!AR_active) || {!((currentWeapon player) isEqualTo AR_weapon)} ||
			{!isNull objectParent player} || {surfaceIsWater (getPos player)} ||
			{_this select 1 == AR_animation && speed (vehicle player) <= 0}) exitWith {
				player removeEventHandler ["AnimDone", _thisEventHandler];
				AR_active = false;
				AR_weapon = nil;
				AR_animation = nil;
			};
			player playMoveNow AR_animation;
		}];
		player playMoveNow AR_animation;
	};
}];
// Stop running (uavView = Tab)
(findDisplay 46) displayAddEventHandler ["KeyDown", {
	if ((_this select 1 == (actionKeys 'MoveForward') select 0) || (_this select 1 == (actionKeys 'vehicleTurbo') select 0) || (_this select 1 == (actionKeys 'uavView') select 0) || (_this select 1 == (actionKeys 'MoveBack') select 0) || (_this select 1 == (actionKeys 'TurnRight') select 0) || (_this select 1 == (actionKeys 'TurnLeft') select 0)) then {
		if (AR_active) then {AR_active = false};
	};
}];
};

 

Share this post


Link to post
Share on other sites

Simple. In your first DEH you can already toggle the auto-run on/off by pressing tab (or any key bind for uavView).

If you want to add WASD and shift, just remove the condition for "uavView" inside second DEH. I'd write it like this:

 

(findDisplay 46) displayAddEventHandler ["KeyDown", {
  if (_this #1 in flatten [actionKeys "MoveForward",actionKeys "vehicleTurbo",actionKeys "MoveBack",actionKeys "TurnRight",actionKeys "TurnLeft"]) then {
   if (AR_active) then {AR_active = false};
  };
}];

 

 

  • Like 1

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

×