Jump to content
jakeplissken

Script to block players from helis if not pilot, blocking from getting in the back.

Recommended Posts

I am working on this event handler to block non-pilots from helis, but this will block players from getting in the passenger spot, and it blocks the scroll menu options when using a drone.

 

inGameUISetEventHandler ["Action", " 
      if (((toUpper typeOf player find toUpper 'Pilot') < 2) && (_this # 0 iskindof 'helicopter') || (_this # 0 iskindof 'plane') && (_this select 3) in ['GetInDriver','GetInPilot','GetInGunner','GetInCommander','GetInCargo']) then { true } else {false};
"];

Am I missing something simple? Player can still get in a ground vehicle, but not helis.

Share this post


Link to post
Share on other sites
12 hours ago, jakeplissken said:

Am I missing something simple?

Yes, GetInMan and SeatSwitchedMan eventhandlers.

Share this post


Link to post
Share on other sites

Here is a good solution though, this will block all non-pilots from Pilot and Copilot seats.

 

player addEventhandler ["GetInMan", {
	params ["_unit", "", "_vehicle"];

	if (_vehicle isKindOf "Air" && {
		!(_vehicle isKindOf "ParachuteBase") && {
			!((vehicle _unit getCargoIndex _unit)>=0) && {
				!((toUpper typeOf _unit find toUpper "Pilot") > -1)}
			}
		}) then {

		_unit moveOut _vehicle;
	};
}];

player addEventhandler ["SeatSwitchedMan", {
	params ["_unit", "", "_vehicle"];

	if (_vehicle isKindOf "Air" && {
		!(_vehicle isKindOf "ParachuteBase") && {
			!((vehicle _unit getCargoIndex _unit)>=0) && {
				!((toUpper typeOf _unit find toUpper "Pilot") > -1)}
			}
		}) then {

		_unit moveOut _vehicle;
	};
}];

 

Share this post


Link to post
Share on other sites

I like to do it in the UI event, is more graceful to prevent access than to allow access then eject.

 

focus on the inGameUISetEventHandler

 

also, since "pilot" is constant, replace 

//replace

toUpper "Pilot"

//with

"PILOT"

 

  • Like 1

Share this post


Link to post
Share on other sites

UI event is neat but you still need a fallback because action menu is not the only way to enter a heli.

 

Heres some more edge cases to consider.

Filtering by "Pilot" in the classname excludes Helicopter Crew units, which you may or may not want depending on your mission.

Co-pilot seats are tricky too. Depending on the scenario, you might want to allow them until someone attempts to actually take controls.

  • Like 1

Share this post


Link to post
Share on other sites

I have found another way, this blocks the pilot seat in Ghosthawk but allows the CoPilot seat, and blocks the "Take Controls" action. But it also stops ground vehicles. How can I restrict it to air vehicles?

 

inGameUISetEventHandler ["Action", "
	if (!((_this select 0) getVariable ['disableGetIn',false]) && (_this select 3) in ['GetInDriver','GetInPilot','GetInGunner','GetInCommander','TakeVehicleControl','UnlockVehicleControl']) then { true }
"];

It does allow the use of the Miniguns in the helicopter though. So nearly there.

 

This is a finished version. I did not realize that _this select 0 was the vehicle.

 

inGameUISetEventHandler ["Action", "

	if (!((_this select 0) getVariable ['disableGetIn',false]) && ((_this select 0) isKindOf 'Air') && (_this select 3) in ['GetInDriver','GetInPilot','GetInGunner','GetInCommander','TakeVehicleControl','UnlockVehicleControl']) then { true }

"];

This works just fine. You can get in ground vehicles and not helis as a non-pilot. Now it is finished.

Edited by jakeplissken
Added finished script.
  • Like 2

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

×