Jump to content
Sign in to follow this  

Recommended Posts

I was wondering if there is a script where only crewmen can drive and gun some vehicles but not all. Some script where i can add class names.

Share this post


Link to post
Share on other sites

I'm interested in this too. I tried modifying the pilotCheck script, but it applies to all vehicles, not just the LAVs. For now I just have my LAV assets secured in a bunker with the Crewmen spawning there and a setVelocity trigger at the entrance which bounces out people who try to enter.

Share this post


Link to post
Share on other sites

Wrote a script for you. A proper solution would be to use lockDriver and lockTurret but its bit more complicated.

In init.sqf:

//Script by Sa-Matra
true spawn {
//List of pilot classes, crewman classes, affected aircraft classes and affected vehicle classes
_pilots = ["B_Helipilot_F"];
_crewmen = ["B_crew_F"];
_aircraft = ["O_Heli_Attack_02_black_F"];
_armor = ["B_APC_Wheeled_01_cannon_F"];

//Wait until player is fully loaded
waitUntil {player == player};

//Check if player is pilot or crewman, you can add more classes into arrays
_iampilot = ({typeOf player == _x} count _pilots) > 0;
_iamcrewman = ({typeOf player == _x} count _crewmen) > 0;

//Never ending cycle
while{true} do {
	//Wait until player's vehicle changed
	_oldvehicle = vehicle player;
	waitUntil {vehicle player != _oldvehicle};

	//If player is inside vehicle and not on foot
	if(vehicle player != player) then {
		_veh = vehicle player;

		//Check if vehicle is aircraft and player is not pilot
		if(({typeOf _veh == _x} count _aircraft) > 0 && !_iampilot) then {
			//Forbidden seats: copilot, gunner, pilot
			_forbidden = [_veh turretUnit [0]] + [gunner _veh] + [driver _veh];
			if(player in _forbidden) then {
				systemChat "You are not pilot and not allowed to pilot or gun this helicopter";
				player action ["eject", _veh];
			};
		};

		//Check if vehicle is armor and player is not crewman
		if(({typeOf _veh == _x} count _armor) > 0 && !_iamcrewman) then {
			//Forbidden seats: gunner, driver
			_forbidden = [gunner _veh] + [driver _veh];
			if(player in _forbidden) then {
				systemChat "You are not crewman and not allowed to drive or gun this vehicle";
				player action ["eject", _veh];
			};
		};
	};
};
};

(with proper tabs: http://pastie.org/pastes/8080976/text )

Change _pilots, _crewmen, _aircraft and _armor to your needs

Edited by SaMatra

Share this post


Link to post
Share on other sites

I'm guessing i would have to put the class names for the vehicle that i wanted only crewmen to be able to driver here?

_armor = [];

Share this post


Link to post
Share on other sites

Yes, for example

_armor = ["B_APC_Wheeled_01_cannon_F", "B_MRAP_01_gmg_F"];

also only crewman will be able to be gunners too. If you want to change that, change

               //Forbidden seats: gunner, driver 
               _forbidden = [gunner _veh] + [driver _veh];

to

               //Forbidden seats: driver 
               _forbidden = [driver _veh];

Share this post


Link to post
Share on other sites

Thanks SaMatra I'm currently using an .fsm written by Cuel that does this but has an issue... notably the pilot check function does not take the copilot into account.. ie: you can enter the vehicle as a non-pilot in the co-pilot seat and then 'take control' of the heli. It would appear your script takes this into account?

Share this post


Link to post
Share on other sites
Thanks SaMatra I'm currently using an .fsm written by Cuel that does this but has an issue... notably the pilot check function does not take the copilot into account.. ie: you can enter the vehicle as a non-pilot in the co-pilot seat and then 'take control' of the heli. It would appear your script takes this into account?

It does

Share this post


Link to post
Share on other sites

Doesn't seem to be working on the Bluefor AMV-7? I have a Rifleman test unit I'm using that can enter it. The choppers work perfect though.

_pilots = ["B_Helipilot_F"];

_crewmen = ["B_crew_F"];

_aircraft = ["B_Heli_Transport_01_F","B_Heli_Attack_01_F","I_Heli_Transport_02_F"];

_armor = ["B_APC_Wheeled_01_Cannon_F"];

---------- Post added at 14:28 ---------- Previous post was at 14:08 ----------

Ok after some further testing - The second block of code for the armored vehicles isn't working.

Share this post


Link to post
Share on other sites
It does

Thanks I'll give it a try

  • Like 1

Share this post


Link to post
Share on other sites
Doesn't seem to be working on the Bluefor AMV-7? I have a Rifleman test unit I'm using that can enter it. The choppers work perfect though.

_pilots = ["B_Helipilot_F"];

_crewmen = ["B_crew_F"];

_aircraft = ["B_Heli_Transport_01_F","B_Heli_Attack_01_F","I_Heli_Transport_02_F"];

_armor = ["B_APC_Wheeled_01_Cannon_F"];

---------- Post added at 14:28 ---------- Previous post was at 14:08 ----------

Ok after some further testing - The second block of code for the armored vehicles isn't working.

There was a typo, _crewman and _crewmen, fixed now.

Share this post


Link to post
Share on other sites

Thanks much!

Also, the class name appears to be case sensitive (plugged in the AMV-7 into the aircraft list earlier to try it out).

B_APC_Wheeled_01_Cannon_F needs to be B_APC_Wheeled_01_cannon_F

Share this post


Link to post
Share on other sites

I wouldn't think they were, it just didn't work with the caps the first time around.

Anyway, got it working 100%, thanks very much!

Share this post


Link to post
Share on other sites

I tired it but it didnt seem to work

/List of pilot classes, crewman classes, affected aircraft classes and affected vehicle classes 
   _pilots = ["B_Helipilot_F"]; 
   _crewmen = ["B_crew_F"]; 
   _aircraft = ["O_Heli_Attack_02_black_F","B_heli_transport_01_F"]; 
   _armor = ["B_APC_wheeled_01_cannon_f"]; 

---------- Post added at 00:33 ---------- Previous post was at 00:26 ----------

Thanks much!

Also, the class name appears to be case sensitive (plugged in the AMV-7 into the aircraft list earlier to try it out).

B_APC_Wheeled_01_Cannon_F needs to be B_APC_Wheeled_01_cannon_F

I think you are right about case sensitive

Share this post


Link to post
Share on other sites

You right about case sensitive, it is an issue with "in" command. For example

"test" in ["TEST"]

returns false, while

"test" == "TEST"

returns true.

Fixed script:

//Script by Sa-Matra
true spawn {
//List of pilot classes, crewman classes, affected aircraft classes and affected vehicle classes
_pilots = ["B_Helipilot_F"];
_crewmen = ["B_crew_F"];
_aircraft = ["O_Heli_Attack_02_black_F"];
_armor = ["B_APC_Wheeled_01_cannon_F"];

//Wait until player is fully loaded
waitUntil {player == player};

//Check if player is pilot or crewman, you can add more classes into arrays
_iampilot = ({typeOf player == _x} count _pilots) > 0;
_iamcrewman = ({typeOf player == _x} count _crewmen) > 0;

//Never ending cycle
while{true} do {
	//Wait until player's vehicle changed
	_oldvehicle = vehicle player;
	waitUntil {vehicle player != _oldvehicle};

	//If player is inside vehicle and not on foot
	if(vehicle player != player) then {
		_veh = vehicle player;

		//Check if vehicle is aircraft and player is not pilot
		if(({typeOf _veh == _x} count _aircraft) > 0 && !_iampilot) then {
			//Forbidden seats: copilot, gunner, pilot
			_forbidden = [_veh turretUnit [0]] + [gunner _veh] + [driver _veh];
			if(player in _forbidden) then {
				systemChat "You are not pilot and not allowed to pilot or gun this helicopter";
				player action ["eject", _veh];
			};
		};

		//Check if vehicle is armor and player is not crewman
		if(({typeOf _veh == _x} count _armor) > 0 && !_iamcrewman) then {
			//Forbidden seats: gunner, driver
			_forbidden = [gunner _veh] + [driver _veh];
			if(player in _forbidden) then {
				systemChat "You are not crewman and not allowed to drive or gun this vehicle";
				player action ["eject", _veh];
			};
		};
	};
};
};

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
Sign in to follow this  

×