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 3

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
On 3/21/2017 at 10:47 PM, 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}",
  		""
];

 

Hi guys im late in the conversation but I have a issue.. I have made a AddRespawnInventory in my InitServer.sqf, ANd I'm trying to block all loudout that are not Pilot or crewmen to get in those type of vih... I understand the script Of NIKANDER, but since my loadout are made from ONE class( In my eden, all my players have the same unit to start then chose from loadout menu a class that I have made up ) this script dosent give me the right path to my loadout.. Her some example

 

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

 

 

this is in my : InitServer.sqf

[resistance,"TFC_C_Soldier_Tunic_Crewman_TW_F"] call BIS_Fnc_addRespawnInventory;
[resistance,"TFC_C_Soldier_Aircrew_Pilot_Helo_TW_F"] call BIS_Fnc_addRespawnInventory;
[resistance,"TFC_C_Soldier_Tunic_Marksman_TW_F"] call BIS_Fnc_addRespawnInventory;
[resistance,"TFC_C_Soldier_OTW_Rifleman_Lite_TW_F"] call BIS_Fnc_addRespawnInventory;
[resistance,"TFC_C_Soldier_Tunic_Grenadier_TW_F"] call BIS_Fnc_addRespawnInventory;
[resistance,"TFC_C_Soldier_OTW_C6_TW_F"] call BIS_Fnc_addRespawnInventory;

 

If someone understand plz help 

Share this post


Link to post
Share on other sites
13 hours ago, Mathieu Trudel said:

have made a AddRespawnInventory in my InitServer.sqf,

but since my loadout are made from ONE class, this script dosent give me the right path to my loadout

 

Get players selected loadout.

Share this post


Link to post
Share on other sites

I am a bit late to reply, but I would strongly recommend the use of event handlers over triggers. This is solely for performance since triggers constantly check a condition at specified intervals, while event handlers are called only when an event takes place.

 

L3TUC3 has provided a decent solution and the only thing I could possibly suggest on top of it is the use of variables to declare which unit is a pilot or not (this will work for both AI and players). For the AI you could do something like the following in the init.sqf. I will assume you have five pilot units and have named them with the convention "pilotX", where 'X' is a number from zero to the number of the pilots minus one.

for private _i from 0 to 4 do {
	(call (compile ("pilot" + (str _i)))) setVariable["isPilot", true, true]; // Set the variable and make it public (not sure this is needed)
};

For the players, you could either add the variable manually, check the Steam ID and add the variable to specific players, or add the variable inside the init field of the units like

// Check if variable is already set because init field runs for every client joining
if(!(this getVariable["isPilot", false]) then {
	this setVariable["isPilot", true, true];
};

After that, you could use the solution that L3TUC3 suggested with some changes as below (using and adapting L3TUC3's code)

this addEventHandler ["GetIn", 
{
	private _spot = _this select 1; // The seat the unit got into
	private _unit = _this select 2; // The unit itself

	if (_spot == "driver" && !(_unit getVariable["isPilot", false])) then // If the unit got into the driver seat doesn't have the isPilot variable set to true
	{ 
		_unit action ["Eject", vehicle _unit]; // Eject the unit
		hint "You are not a Pilot!" // Show a hint
	};
		
}]; 

this addEventHandler ["SeatSwitched", 
{
	_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" && !(_unit1 getVariable["isPilot", false])) then { _unit1 action ["Eject", _vehicle]; };
	if (_spot2 == "driver" && !(_unit2 getVariable["isPilot", false])) then { _unit2 action ["Eject", _vehicle]; };
		
}]; 

In essence, I have just removed the arrays with the pilots and have changed the checks inside the if statements to get the variables of the units (if not set, false is returned).

 

I hope this helps somehow. If not, or if you have more questions please don't hesitate to ask :).

  • Like 1

Share this post


Link to post
Share on other sites

thx to all !! 

 

I'm looking for a script / add action or something to : what ever loadout the players will take ( in Mp on a private server ) , once they enter a helo, or a tank in driver copilot, commander and gunner, they automaticly get a loadout i've made .. It would be simpler for what i need. 

I have tried a add action, but Its not automatic, .. 

 

OR maybe just, In the Init of the vech, taht the player need the proper headgear of be eject ?? it that possibe ?? I'm sure it is it ARMA !!:P 

 

thx again with my struggling 

 

Share this post


Link to post
Share on other sites

im trying this

chopper1 addEventHandler ["GetIn", {

_vehicle = _this select 0;

_seat = _this select 1;

_unit = _this select 2;

 

_pilotSeats = [ "driver", "gunner" ];

_pilotUniforms = [ "U_B_HeliPilotCoveralls", "U_O_PilotCoveralls" ];

_pilotHelmets = [ "H_PilotHelmetHeli_B", "H_PilotHelmetHeli_O" ];

 

if( ( _seat in _pilotSeats ) ) then {

if( !( ( uniform _unit ) in _pilotUniforms ) || !( ( headgear _unit ) in _pilotHelmets ) ) then { _unit action [ "eject", _vehicle ]; }; }; } ];

 

but it not working .. 

 

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

×