GioLabo 2 Posted March 21, 2017 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
L3TUC3 32 Posted March 22, 2017 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]; }; }]; 4 Share this post Link to post Share on other sites
Nikander 123 Posted March 22, 2017 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}", "" ]; 2 Share this post Link to post Share on other sites
GioLabo 2 Posted March 22, 2017 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
Nikander 123 Posted March 22, 2017 (edited) 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 March 22, 2017 by Nikander Share this post Link to post Share on other sites
GioLabo 2 Posted March 22, 2017 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 1 Share this post Link to post Share on other sites
Mathieu Trudel 0 Posted November 13, 2020 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
Larrow 2820 Posted November 14, 2020 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
ZaellixA 383 Posted November 14, 2020 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 :). 2 Share this post Link to post Share on other sites
Mathieu Trudel 0 Posted November 14, 2020 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
Mathieu Trudel 0 Posted November 15, 2020 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
Lucas Andre (Lunga Gamer) 3 Posted February 10, 2023 On 11/14/2020 at 3:42 PM, ZaellixA said: 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 :). When I go to run the script it shows error. In: this addEventHandler ["GetInDriver",https://imgur.com/qAz6Jzc Another question, how do I put more than one position? Like, Heli pilot and Fighter Pilot? Share this post Link to post Share on other sites
Harzach 2517 Posted February 10, 2023 2 hours ago, Lucas Andre (Lunga Gamer) said: When I go to run the script How and where are you running it? 1 Share this post Link to post Share on other sites
Lucas Andre (Lunga Gamer) 3 Posted February 11, 2023 I managed to get it to work, I modified it and it's perfect. 1 Share this post Link to post Share on other sites
ZaellixA 383 Posted February 11, 2023 Would you care to share the modification so that people could benefit from it in the future? Additionally, if there's an error I could (and should) fix it in the snippet I provided too so that we won't convey false information to other users. Share this post Link to post Share on other sites
Lucas Andre (Lunga Gamer) 3 Posted February 11, 2023 Actually I'm using this script, and it works perfect.init.sqf Spoiler ["Helicopter","B_Helipilot_F"] execVM "scripts\b2_checkPilot.sqf"; // Edit what you want to block ["Helicopter","B_Pilot_F"] execVM "scripts\b2_checkPilot.sqf"; // Edit what you want to block ["Plane","B_Fighter_Pilot_F"] execVM "scripts\b2_checkPilot.sqf"; // Edit what you want to block ["Heli_Attack_01_base_F","B_Helipilot_F"] execVM "scripts\b2_checkGunner.sqf"; // Edit what you want to block ["B_Heli_Light_01_dynamicLoadout_F","B_Helipilot_F"] execVM "scripts\b2_checkGunner.sqf"; // Edit what you want to block \scripts\b2_checkGunner.sqf Spoiler /////////////////////////////////////////////////////////////////////////////////////////////////// // B2 Check Gunner Script v1.07 // // Execute from mission init.sqf // // [class,vehicleType] execVM "scripts\b2_checkGunner.sqf"; // // ["Heli_Attack_01_base_F","B_Helipilot_F"] execVM "scripts\b2_checkGunner.sqf"; // // ["Wheeled_APC_F","B_Crew_F"] execVM "scripts\b2_checkGunner.sqf"; // /////////////////////////////////////////////////////////////////////////////////////////////////// if (isDedicated) exitWith {}; private ["_vehType","_crewType","_crewTypeName","_veh","_seats"]; while {(true)} do { _vehType = _this select 0; _crewType = _this select 1; _crewTypeName = getText(configFile >> "CfgVehicles" >> _crewType >> "displayName"); if (typeOf player != _crewType) then { waitUntil {vehicle player != player}; _veh = vehicle player; if (_veh isKindof _vehType && !(_veh isKindOf "ParachuteBase")) then { _seats = [gunner _veh]; if (_veh isKindOf "Tank") then {_seats = _seats + [_veh turretUnit [0]]; }; if (_veh isKindOf "Heli_Transport_01_base_F") then {_seats = _seats + [_veh turretUnit [2]];}; if (player in _seats) then { player action ["GetOut",_veh]; waitUntil {vehicle player == player}; hint format ["RESTRICTED VEHICLE\n\nRequired class: %1",_crewTypeName]; }; }; }; }; scripts\b2_checkPilot.sqf Spoiler /////////////////////////////////////////////////////////////////////////////////////////////////////// // B2 Check Pilot Script v1.07 // // Execute from mission init.sqf // // [class,vehicleType] execVM "scripts\b2_checkPilot.sqf"; // // ["Helicopter","B_Helipilot_F"] execVM "scripts\b2_checkPilot.sqf"; // // ["Helicopter","B_Pilot_F"] execVM "scripts\b2_checkPilot.sqf"; // // ["Plane","B_Fighter_Pilot_F"] execVM "scripts\b2_checkPilot.sqf"; // // ["Wheeled_APC_F","B_Crew_F"] execVM "scripts\b2_checkPilot.sqf"; // ///////////////////////////////////////////////////////////////////////////////////////////////////////// if (isDedicated) exitWith {}; private ["_vehType","_crewType","_crewTypeName","_veh","_seats"]; while {(true)} do { _vehType = _this select 0; _crewType = _this select 1; _crewTypeName = getText(configFile >> "CfgVehicles" >> _crewType >> "displayName"); if (typeOf player != _crewType) then { waitUntil {vehicle player != player}; _veh = vehicle player; if (_veh isKindOf _vehType && !(_veh isKindOf "ParachuteBase")) then { _seats = [driver _veh]; if (_veh isKindOf "Helicopter") then {_seats = _seats + [_veh turretUnit [0]];}; if (player in _seats) then { player action ["GetOut",_veh]; waitUntil {vehicle player == player}; hint format ["RESTRICTED VEHICLE\n\nRequired class: %1",_crewTypeName]; if (isEngineOn _veh) then {_veh engineOn false}; }; }; }; }; scripts\b2_restrictions.sqf Spoiler /////////////////////////////////////////////////////////////////////////////////////////////////// // B2 Weapon Restriction Script v1.01 // // Execute from mission init.sqf // // [classesArray,weaponsArray] execVM "scripts\b2_restrictions.sqf"; // // 0 = [["B_recon_M_F"],["srifle_GM6_F","srifle_LRR_F"]] execVM "scripts\b2_restrictions.sqf"; // /////////////////////////////////////////////////////////////////////////////////////////////////// if (isDedicated) exitWith {}; private ["_r_class","_r_weap","_p_weap","_p_weap_base","_p_weap_base2","_p_weap_name","_s_weap","_s_weap_base","_s_weap_base2","_s_weap_name"]; while {true} do { sleep 1; _r_class = _this select 0; _r_weap = _this select 1; _p_weap = primaryWeapon player; _p_weap_base = configName(inheritsFrom (configFile >> "CfgWeapons" >> _p_weap)); _p_weap_base2 = configName(inheritsFrom (configFile >> "CfgWeapons" >> _p_weap_base)); _p_weap_name = getText(configFile >> "CfgWeapons" >>_p_weap >> "displayName"); _s_weap = secondaryWeapon player; _s_weap_base = configName(inheritsFrom (configFile >> "CfgWeapons" >> _s_weap)); _s_weap_base2 = configName(inheritsFrom (configFile >> "CfgWeapons" >> _s_weap_base)); _s_weap_name = getText(configFile >> "CfgWeapons" >>_s_weap >> "displayName"); if (((_p_weap in _r_weap) || (_p_weap_base in _r_weap) || (_p_weap_base2 in _r_weap)) && !(typeOf player in _r_class)) then { player removeWeapon _p_weap; hint format ["RESTRICTED WEAPON\n\nYou are not qualified\nto use %1",_p_weap_name]; }; if (((_s_weap in _r_weap) || (_s_weap_base in _r_weap) || (_s_weap_base2 in _r_weap)) && !(typeOf player in _r_class)) then { player removeWeapon _s_weap; hint format ["RESTRICTED WEAPON\n\nYou are not qualified\nto use %1",_s_weap_name]; }; } forEach allUnits; The good thing about it is that in addition to blocking non-pilot access, it also blocks non-gunner access. But you can remove the gunner option and allowed weapons. It's all editable. 2 Share this post Link to post Share on other sites
bodybaq 18 Posted August 6 On 3/22/2017 at 8:35 PM, 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 How would this look if you require pilot + name? Share this post Link to post Share on other sites