Jump to content

Recommended Posts

Greets guys (and girls if there are any) !

 

I need a script bu which only pilots can use choppers and planes. Can anyone explain how to do that? 

 

Thanks

 

Share this post


Link to post
Share on other sites

There's a variety of ways to do it.

 

I would use a GetIn and SeatSwitched eventhandler on the vehicle:

 

The GetIn EH will fire when a unit enters a vehicle. You can then check if the unit is in an allowed slot.

 

The same for SeatSwitched (if the unit entered into cargo first, then switched to a pilot seat).

 

The following will probably not work for all situations, but should get you started:

this addEventHandler ["GetIn", 
{
	_pilots = [pilot1,pilot2]; //variable names of the pilot slot objects
	_spot = _this select 1; //the seat the unit got into
	_unit = _this select 2; //the unit itself

	if (_spot == "driver" && !(_unit in _pilots)) then //if the unit got into the driver seat and is not a pilot
	{ 
		_unit action ["Eject", vehicle _unit]; //eject the unit
		hint "You are not a Pilot!" //show a hint
	};
		
}]; 

this addEventHandler ["SeatSwitched", 
{
	_pilots = [pilot1,pilot2]; //variable names of the pilot slot objects
	_vehicle = _this select 0; //the vehicle the seats were switched in
	_unit1 = _this select 1; //the unit initiating the switching
	_unit2 = _this select 2; //the unit that got switched (if not an emty seat)
	_spot1 = assignedVehicleRole _unit1; //the new seat for unit 1
	_spot2 = assignedVehicleRole _unit2; //the new seat for unit 2

	if (_spot1 == "driver" && !(_unit in _pilots)) then { _unit1 action ["Eject", vehicle _unit1]; };
	if (_spot2 == "driver" && !(_unit in _pilots)) then { _unit2 action ["Eject", vehicle _unit2]; };
		
}]; 

 

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, GioLabo said:

I need a script bu which only pilots can use choppers and planes

 

I fancy triggers

_trig = createTrigger ["EmptyDetector",[0, 0, 0],false];
_trig setTriggerStatements [
  		"vehicle player isKindOf 'Air'",
  		"if (!(player isKindOf 'B_Pilot_F') && {assignedVehicleRole player in [['driver'],['Turret',[0]]]}) then {moveOut player}",
  		""
];

 

  • Like 1

Share this post


Link to post
Share on other sites
16 hours ago, Nikander said:

 

I fancy triggers


_trig = createTrigger ["EmptyDetector",[0, 0, 0],false];
_trig setTriggerStatements [
  		"vehicle player isKindOf 'Air'",
  		"if (!(player isKindOf 'B_Pilot_F') && {assignedVehicleRole player in [['driver'],['Turret',[0]]]}) then {moveOut player}",
  		""
];

 

and where should I put it or place the name of pilots?

Share this post


Link to post
Share on other sites
36 minutes ago, GioLabo said:

and where should I put it or place the name of pilots?

 

If you want to use names then try this

private ["_name", "_trig"];

_name = ["GioLabo", "Nikander"];
_trig = createTrigger ["EmptyDetector",[0, 0, 0],false];
_trig setTriggerStatements [
  		"vehicle player isKindOf 'Air'",
  		format ["if (!(name player in %1) && {assignedVehicleRole player in [['driver'],['Turret',[0]]]}) then {moveOut player}", _name],
  		""
];

and you can always put it in init.sqf if you find nowhere else more appropriate

Edited by Nikander

Share this post


Link to post
Share on other sites
48 minutes ago, Nikander said:

 

If you want to use names then try this


private ["_name", "_trig"];

_name = ["GioLabo", "Nikander"];
_trig = createTrigger ["EmptyDetector",[0, 0, 0],false];
_trig setTriggerStatements [
  		"vehicle player isKindOf 'Air'",
  		format ["if (!(name player in %1) && {assignedVehicleRole player in [['driver'],['Turret',[0]]]}) then {moveOut player}", _name],
  		""
];

and you can always put it in init.sqf if you find nowhere else more appropriate

oh thanks bro, Now I hot it

  • 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

×