Jump to content
IIIXJokerXIII

Anyway to check when a player leans

Recommended Posts

I need a way to check if a player is leaning left or right or an event/trigger when a player leans left or right. I've search for a way to do this for a few weeks now but no luck. If anyone has any ideas will you please help point me in the right direction  *HELP* 

The reason I'm trying to do this I would to make it so when a player leans left or right it will force camera view from "EXTERNAL" to switch camera "INTERNAL". Again thanks for any help on this!!!

 

Things I've looked at animationState but that didn't work.

Maybe there is a way to see when a player does this? but I know some users use custom keys so I'm not sure how to go this way.  I'm so lost on this one lol =-O 
keyLeanLeft[]={16};
keyLeanRight[]={18};
keyLeanLeftToggle[]={272};
keyLeanRightToggle[]={274};

Share this post


Link to post
Share on other sites

As you already have the KeyCodes, why not use this

something like 

mk = (findDisplay 46) displayAddEventHandler ["KeyDown", "
	if ((_this select 1) in [16,18,272,274] ) then {
	hint "Do Stuff";
	};
"];

Same goes for 'KeyUp'. Not quite sure if it is '_this select 1' or an other one.

Share this post


Link to post
Share on other sites

Thank you so much you all lead me in the right direction.  I need to get you guys a beer!  :drinking2:  This is the base part of my code here but on mine I have it to force INTERNAL for other things like freelook and stuff.

[] spawn {
	while {vehicle player == player} do {
		if ((inputAction "LeanLeft" > 0) || (inputAction "LeanRight" > 0) || (inputAction "LeanLeftToggle" > 0) || (inputAction "LeanRightToggle" > 0)) then {
			XMCPV_PlayerCombatModeTimer = 120;
			while {XMCPV_PlayerCombatModeTimer  > 0} do {
				if (vehicle player == player && cameraView == "External") then {player switchCamera "Internal";};
				XMCPV_PlayerCombatModeTimer  = XMCPV_PlayerCombatModeTimer  - 1;
				if ((inputAction "LeanLeft" > 0) || (inputAction "LeanRight" > 0) || (inputAction "LeanLeftToggle" > 0) || (inputAction "LeanRightToggle" > 0)) then {
					XMCPV_PlayerCombatModeTimer = 120;
				};
				uisleep 0.10;
			};
		};
		uisleep 0.10;
	};
};

Video of the code in actions Youtube Video

Share this post


Link to post
Share on other sites

Oh right, I forgot about that little exploit. Good idea!

Share this post


Link to post
Share on other sites

I would recommend, using an approach with Eventhandlers , therefor you don't stress the scheduler. 

Share this post


Link to post
Share on other sites
On 4/23/2017 at 5:16 PM, crewt said:

I would recommend, using an approach with Eventhandlers , therefor you don't stress the scheduler. 

Not sure how I would go about eventhandlers with inputAction but if you have an idea to get me started I will see what I can come up with :f:

Share this post


Link to post
Share on other sites
mk = (findDisplay 46) displayAddEventHandler ["KeyDown", "
    params [""_ctrl"", ""_dikCode"", ""_shift"", ""_ctrlKey"", ""_alt""];
    if (!_shift && !_ctrlKey && !_alt) then {
        if (_dikCode in [16,18,272,274]) then {
               Systemchat ""you shall not buguse"";
        };
    };
"];

Here you go, this should trigger every time someone is leaning left or right, not sure about the other two dikCodes you provided (272 , 274). General, the system doen't constantly wait and keeps checking what the player is doing.

 

 

(But it's late, there might be a typo somewhere in it)

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

×