Jump to content
Sign in to follow this  
Blitzer134

pilot check loop ?

Recommended Posts

what is the best way to loop this script

chopper1 addEventHandler ["GetIn", { 
       _vehicle = _this select 0; 
       _seat = _this select 1; 
       _unit = _this select 2; 

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

       if( ( _seat in _pilotSeats ) ) then { 
           if( !( _unit getVariable [ "PilotCanFly", false ] ) ) then { 
               _unit action [ "eject", _vehicle ]; 
           }; 
       }; 
   } 
]; 
chopper2 addEventHandler ["GetIn", { 
       _vehicle = _this select 0; 
       _seat = _this select 1; 
       _unit = _this select 2; 

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

       if( ( _seat in _pilotSeats ) ) then { 
           if( !( _unit getVariable [ "PilotCanFly", false ] ) ) then { 
               _unit action [ "eject", _vehicle ]; 
           }; 
       }; 
   } 
]; 	

Share this post


Link to post
Share on other sites

Searching would be the best way. There's been dozens of posts about this very issue already, some pretty recent.

Share this post


Link to post
Share on other sites

For more than just pilots, SaMatra did awesome work! Set the forbidden seats, vehicles and operators/crew to your liking. Remove the other restrictions if undesired.

crewCheck.sqf

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

   //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) in _pilots;
   iamcrewman = (typeOf player) in _crewmen;
   iamdiver = (typeOf player) in _diver;

   //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) in _aircraft && !iampilot) then {
               //Forbidden seats: copilot, gunner, pilot
               [b]_forbidden = [_veh turretUnit [0]] + [gunner _veh] + [driver _veh];[/b]
               if(player in _forbidden) then {
                   systemChat "You are not authorized to operate this aircraft!";
                   player action ["eject", _veh];
               };
           };

           //Check if vehicle is armor and player is not crewman
           if((typeOf _veh) in _armor && !iamcrewman) then {
               //Forbidden seats: gunner, driver
              [b] _forbidden = [driver _veh] + [gunner _veh];[/b]
               if(player in _forbidden) then {
                   systemChat "You are not authorized to operate this vehicle!";
                   player action ["eject", _veh];
               };
           };

   //Check if vehicle is armor and player is not crewman
          if((typeOf _veh) in _sub && !iamdiver) then {
              //Forbidden seats: gunner, driver
             [b] _forbidden = [_veh turretUnit [0]] + [gunner _veh] + [driver _veh];[/b]
              if(player in _forbidden) then {
                  systemChat "You are not authorized to operate this submersible!";
                  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  

×