Jump to content

rkemsley

[SOLVED]Ejecting Units from Certain Seats

Recommended Posts

I am currently trying to make it so that when a hold action is preformed on a crate, it will put the crate in the back of a non specific Zamak Truck.
This would mean that the seats in the back of the truck would have to be locked and anyone sitting in the truck must be ejected from those seats.

This is my script so far, all working fine.
 

[
	this,
	"Load.",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",
	"_this distance _target < 3",
	"_caller distance _target < 3",
	{},
	{},
	{ _this call 
		{
		_ZamakTrans = nearestObjects [ _this select 0, [ "Truck_02_transport_base_F" ], 25 ];
		if (count _ZamakTrans > 0) then
			{
			target = _ZamakTrans select 0;
			{ target lockCargo [ _x,true ] } forEach [ 2, 3, 4, 5, 6, 7 ];
			box attachTo [ target, [ 0, 0.25, -0.15 ] ];
			box setVectorDirAndUp [ [ 1, 0, 0], [0, 0, 1 ] ];
			};
		}
	},
	{},
	[],
	2,
	Nil,
	true,
	false
] remoteExec [ "BIS_fnc_holdActionAdd", 0, this ];


All I need at the moment is to be able to eject people from the seats 2, 3 4, 5, 6 and 7.

(any advice/criticism on my script will be greatly appreciated.)

Share this post


Link to post
Share on other sites

You can use the moveOut command to safely kick a unit from a vehicle, but then you need a way to determine which units need to be kicked.

The fullCrew command returns an array which also gives the cargo index for each unit in the vehicle.

You can compare that to your list of cargo indexes like such (quick and dirty):

 

_ZamakTrans = nearestObjects [ _this select 0,["Truck_02_transport_base_F"],25];
if (count _ZamakTrans > 0) then {
	target = _ZamakTrans select 0;
	
	// Kick units from cargo slots and lock them
	_lockIndexes = [2,3,4,5,6,7];
	{if ((_x select 2) in _lockIndexes) then {moveOut (_x select 0)};} forEach fullCrew target;
	{target lockCargo [_x,true];} forEach _lockIndexes
	
	// Attach box
	box attachTo [target,[0,0.25,-0.15]];
	box setVectorDirAndUp [[1,0,0],[0,0,1]];
};

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hello there rkemsley !

 

Here is also a workaround in order to use the script for every vehicle :

//___________________	Count all available seats including cargo slots	___________________

_Seats_Number = [_Helicopter,true] call BIS_fnc_crewCount;	

systemchat format ['Vehicle: %1		seats:	%2', _Helicopter , _Seats_Number];


//___________________	 Counts all available seats excluding cargo slots	___________________

_Seats_Crew = [_Helicopter,false] call BIS_fnc_crewCount;
//___________________	 Counts all cargo slots	___________________

_Seats_Cargo = _Seats_Number - _Seats_Crew;	

{	
	unassignvehicle _x;
	//_x action ["Eject", vehicle _x];	//	one by one
	moveOut _x;	//	move out at once
	}foreach units _this;
}foreach units _Group;

part of the code below :

(WIP ) GF_Zone_Spawner

  Reveal hidden contents

 

  • Like 2

Share this post


Link to post
Share on other sites

@Sgt. Dennenboom

Thank you very much!

_ZamakTrans = nearestObjects [ _this select 0,["Truck_02_transport_base_F"],25];
if (count _ZamakTrans > 0) then {
	target = _ZamakTrans select 0;
	
	// Kick units from cargo slots and lock them
	_lockIndexes = [2,3,4,5,6,7];
	{if ((_x select 2) in _lockIndexes) then {moveOut (_x select 0)};} forEach fullCrew target;
	{target lockCargo [_x,true];} forEach _lockIndexes
	
	// Attach box
	box attachTo [target,[0,0.25,-0.15]];
	box setVectorDirAndUp [[1,0,0],[0,0,1]];
};

This was perfect! Just had to make one minor change to the code so it would work.

[
	this,
	"Load.",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa",
	"_this distance _target < 3",
	"_caller distance _target < 3",
	{},
	{},
	{ _this call 
		{
		_ZamakTrans = nearestObjects [ _this select 0, [ "Truck_02_transport_base_F" ], 25 ];
		if ( count _ZamakTrans > 0 ) then
			{
			target = _ZamakTrans select 0;
			_lockIndexes = [ 2, 3, 4, 5, 6, 7 ];
			{ if ( ( _x select 2 ) in _lockIndexes ) then { moveOut ( _x select 0 ) }; } forEach fullCrew target;
			{ target lockCargo [ _x, true ]; } forEach _lockIndexes;
			box attachTo [ target, [ 0, 0.25, -0.15 ] ];
			box setVectorDirAndUp [ [ 1, 0, 0], [0, 0, 1 ] ];
			};
		}
	},
	{},
	[],
	2,
	Nil,
	true,
	false
] remoteExec [ "BIS_fnc_holdActionAdd", 0, this ];

 ^^ For anyone who would like to replicate what I've done.

If the Zeus player is sitting in the position which gets locked while in Zeus mode, he will not be kicked out of the vehicle.

 

Edited by rkemsley
  • Like 1
  • Thanks 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

×