Jump to content
Posenpaul

[SOLVED] Help needed: Sit on Chair and Stand Up for Players (no ACEX)

Recommended Posts

Hello Arma Friends,

first of all I have to say I'm not an experienced scripter or coder, but normally I get my (simple) scripts done with search function here, YT vids and learning by doing, but I'm stuck on this and need help. I will explain what I already tried.


I was not able to find a good mod/script for sitting on chair (except ACEX and we're not using ACE) or SlideShows and for the next 5-6 missions we want to have those two features in our 8-10 people coop missions. 
Slideshow on tv screen was simple and done! 🙂

Sit down and stand up was also ok, but in a normal building or anywhere else, but we're starting our mission from the aircraft carrier that comes with Vanilla Arma (USS Freedom). On this carrier I have problems to get my player sit down on the chairs correctly. I tried different things with getPos and setPos, but that doesn't work on the aircraft carrier, so, I tried setPosWorld and getPosWorld to get the Z value right.
Also, this will not work, anything I tried my soldier will sit 1m above the chair or will be in the water below the aircraft carrier.

So, now, I tried attachTo, and with this I get my soldier perfectly sit on the chair on the aircraft carrier, but problem is after attachTo player is not able to do any actions or at least look around. Is there any possibility to give player the option to look around and use action menu after attachTo? Or is this the complete wrong way I'm trying. 
Thanks in adcvance for any help or just link to wiki where I can find my answers myself. 

Code for sitting down (addAction in chair):

Spoiler

_chair = _this select 0;
_unit = _this select 1;

 

[_unit,"HubSittingChairB_idle3"] remoteExec ["switchmove",0];
_unit attachTo [_chair, [0, 0, -0.28]];
_unit setDir -180;

 

_unit addAction ["Aufstehen", "scripts\aufstehen.sqf"];
 


Code for stand up (not tried yet because of the above mentioned problem):
 

Spoiler

_unit = _this select 1;
_standUp = _this select 2;

 

_unit setPos (getPos _unit [0,0.5,0];
_unit detach;
[_unit,""] remoteExec ["switchmove",0];

 

_unit removeAction _standUp;
 

 

  • Like 1

Share this post


Link to post
Share on other sites

Have you tried with setPosASL or setPosATL yet? I'm fairly sure if I remember correctly that setPosASL ignores waves (I should really check that though) but if you're on a static object over water then setPosATL should work anyway as it just takes it's z value from the sea bed.

  • Like 1

Share this post


Link to post
Share on other sites

Hi beno_83au,
 

thanks for your fast answer, I tried both and had same issues, but after looking into setPosASL and setPosATL I was really questionig if it is the script and tried another chair. 

Ok here is what the same script with setPosATL (not attachTo) does with different original (not modded or creatorDLC based) Arma3 chairs. 

 

Normal plastic chair (Land_CampingChair_v2_F):

 

Rugged desk chair (Land_DeskChair_01_olive_F)
 

 

 

On the rugged desk chair I can adjust the z level without any influence, but above -1.2 he will sit 1 meter above the chair, -1.21 or more he will drop into the water below the aircraft carrier.
So, my problem was solved, even with setPos and getPos it will work now if I use other chairs, but I will use setposATL, because it seems more reliable. Thank you beno_83au.

I will not close the thread right now, I will test my scripts tomorrow with friends on dedicated server and maybe I have additional questions, but if all work fine on dedicated I will share my final scripts here. 

  • Like 3

Share this post


Link to post
Share on other sites

Hi Arma friends,

 

so here is now what I got. Tried on dedicated and seems to work fine, even with JIP people. 

 

I get rid of the second script and have now all in one script. 

with addAction in init of chair:

Spoiler

_chair = _this select 0;
_unit = _this select 1;
_action = _this select 2;


[_chair, _action] remoteExec ["removeAction", 0, true];                                                                                                                     //sit Down, remove sit down action from chair
[_unit,"HubSittingChairB_idle3"] remoteExec ["switchmove",0];
_unit setDir (getDir _chair) -180;
_unit setPosATL [getPosATL _chair select 0, (getPosATL _chair select 1)+0.11, (getPosATL _chair select 2)-0.1];


sleep 0.5;

 

_unit addAction ["<t color ='#00FF00'>Aufstehen</t>", {                                                                                                                //give player action for stand up and delete this action once used
    _unit = _this select 0;
    _standUp = _this select 2;
    _unit setPosATL [getPosATL _unit select 0, (getPosATL _unit select 1)+0.75, getPosATL _unit select 2];
    [_unit,""] remoteExec ["switchmove",0];
    [_unit, _standUp] remoteExec ["removeAction", 0, true];
    },
    nil, 1.5,true, true,"","true", 1,false,"",""
];

 

sleep 0.5;
                                                                                                                                                                                                                   //check for player distance to chair, if more than 1m add sit down action again to chair
while {(_unit distance _chair) < 1} do {sleep 1};
[_chair, ["<t color ='#00FF00'>Hinsetzen</t>", "scripts\hinsetzen.sqf",nil, 1.5,true, true,"","true", 1,false,"",""]] remoteExec ["addAction", 0, true];
 



The only thing I hate about this script is that players can spin around on the chair after sitting down. Is there any possibility to avoid this. Perfect will be head movement still allowed, but all other movement not. Like disableAI "MOVE" for AI, but only for players.
I tried enableSimulation, but that will freeze the whole unit and my player should be able to look around.

Thanks in advance for any help. 

Share this post


Link to post
Share on other sites
On 10/20/2021 at 11:42 PM, Posenpaul said:


The only thing I hate about this script is that players can spin around on the chair after sitting down. Is there any possibility to avoid this. Perfect will be head movement still allowed, but all other movement not. Like disableAI "MOVE" for AI, but only for players.
I tried enableSimulation, but that will freeze the whole unit and my player should be able to look around.

Thanks in advance for any help. 

 

Nobody any idea ho to make this? Thanks. 

Share this post


Link to post
Share on other sites

This is a pretty hacky solution but you could use attachTo initially, then run a loop that waits until freelook is enabled and the detach the player and use setPos. Then wait until freelook is disabled and use attachTo again.....

 

while {NeedsToBeSitting} do {
	waitUntil {freeLook};
	//detach and setPos
	waitUntil {!freeLook};
	//attachTo
};

https://community.bistudio.com/wiki/freeLook

Work that in somewhere and it should be able to cover it. You'd most likely set that NeedsToBeSitting variable on the server, the run the freeLook check local to each player after they sit down (and terminate it once they stand up).

 

I thought there might've been a way to override mouse movement inputs but didn't get to working that one out. Otherwise you could've just used that instead of the attaching and detaching.

  • Like 1

Share this post


Link to post
Share on other sites

Hi beno_83au,

 

thanks, I found my own "hacky" workaround. After I give the unit the action for standUp he will constantly check the direction. As setDir will not have any influence on freeLook, player will sit on the chair in the right direction, but is able to use freeLook.


 

Quote

while {_checkDir} do {                                                // Force Player Dir
  _unit setDir (getDir _chair) -180;
  if ((_unit distance _chair) > 1 ) then {_checkDir = false;};
};

 

 

The whole script:
 

Quote

 

_chair = _this select 0;
_unit = _this select 1;
_action = _this select 2;
_checkDir = true;


[_chair, _action] remoteExec ["removeAction", 0, true];                 //sit Down, remove sit down action from chair
[_unit,"DefaultPassenger"] remoteExec ["switchmove",0];
_unit setDir (getDir _chair) -180;
_unit setPosATL [getPosATL _chair select 0, (getPosATL _chair select 1)+0.11, (getPosATL _chair select 2)-0.1];


sleep 0.5;

_unit addAction ["<t color ='#00FF00'>Aufstehen</t>", {                //give player action for stand up and delete this action once used
    _unit = _this select 0;
    _standUp = _this select 2;
    _unit setPosATL [getPosATL _unit select 0, (getPosATL _unit select 1)+0.75, getPosATL _unit select 2];
    [_unit,""] remoteExec ["switchmove",0];
    [_unit, _standUp] remoteExec ["removeAction", 0, true];
    },
    nil, 1.5,true, true,"","true", 1,false,"",""
];

 

while {_checkDir} do {                                                                             // force Player Dir
  _unit setDir (getDir _chair) -180;
  if ((_unit distance _chair) > 1 ) then {_checkDir = false;};

};
 

sleep 0.5;
                                                                                                                   //check for player distance to chair, if more than 1m add sit down action again to chair
while {(_unit distance _chair) < 1} do {sleep 1};
[_chair, ["<t color ='#00FF00'>Hinsetzen</t>", "scripts\hinsetzen.sqf",nil, 1.5,true, true,"","true", 1,false,"",""]] remoteExec ["addAction", 0, true];

 

 

I think this is solved as good as I can with my little knowledge of SQF.

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the input Pierre,

I'm not at home currently I will check it out this evening or if too tired tomorrow. I will let you know how it works. 🙂

 

btw Thanks for the Mag repack Script, use this in all my missions. So simple, soooo good. 🙂

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Tried it, for me disableUserInput will always block the whole input or the mouse will stuck in last movement. 

I'm not able to see how this should solve my problem for only headmovement possible when sitSown ist active. Further soldier is not able to use mouse for the Action to stand up again.  

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

×