luxcapere 11 Posted January 12, 2017 This is the code I have. It is in an sqf file and is run by an exec command in the init. class Only_Pilots_Fly{ //this setVariable ["PilotCanFly", true] ~ use this to allow a unit to fly put in unit init _choppers addEventHandler ["GetIn", { _vehicle = _this select 0; _seat = _this select 1; _player = unitsGlobalVariable; _pilotSeats = [ "driver", "gunner" ]; if( ( _seat in _pilotSeats ) ) then { if( ( _player getVariable ["PlayerCanFly"=="false"] ) ) then { _player action [ "eject", _vehicle ]; }; }; }; }; here is the relevant part of my init. unitsGlobalVariable = player1,w1,w2,w3,w4,w5,w6,w7,w8,w9,w10,w11,w12,w13,w14,w15,w16,w17,w18,w19,w20,w21,w22,w23,w24,w25,w26,w27,w28,w29,w30,w31,w32,w33,w34,w35,w36,w37,w38,w39,w40,w41,w42,w43,w44,w45,w46; //put all your player unit vars here ; //place all your choppers in this array for only pilot fly script _choppers = ["CH1","CH2","CH3","CH4","CH5"], {[0,0] exec "Only_Pilots_Fly.sqf"} foreach _choppers; What I am trying to do is combine modified elements of two scripts provided for public use here on the forums. The one script which has no known problems and runs separately of the one I am having issues with is meant to give players the same loadout they spawned with on respawn. I am using the same list of variables as the other script I am using except they are stored in a global variable for ease of use. The one I am currently having problems with restricts the ability to be in the pilot or copilot seat of the specified aircraft based on a command typed in a player units' init. I am new to mission making using scripts so any and all help is appreciated and detailed, noob-friendly explanations of the solution to this issue, if you know it, couldn't hurt! Also, the error is thrown when I preview the mission, not when I get in a chopper. Share this post Link to post Share on other sites
f2k sel 164 Posted January 12, 2017 Don't know if it will fix the issue but there is an error here you need to use execvm not exec {[0,0] exec "Only_Pilots_Fly.sqf"} foreach _choppers; Share this post Link to post Share on other sites
Nikander 122 Posted January 12, 2017 Assuming you want to reference a Variable Name set in attributes of each chopper using the built-in Editor, here is what I would try in the "relevant part of your init" _choppers = [ch1, ch2, ch3, ch4, ch5]; _choppers execVM "Only_Pilots_Fly.sqf"; and then, altering the script that you call using execVM like so { _x addEventHandler ["GetIn", { _vehicle = _this select 0; _seat = _this select 1; _player = _this select 2; _pilotSeats = ["driver", "gunner"]; if (_seat in _pilotSeats) then { if !(_player getVariable ["PlayerCanFly", false]) then { _player action ["eject", _vehicle]; }; }; }]; } forEach _this; I hope this helps Share this post Link to post Share on other sites
luxcapere 11 Posted January 12, 2017 alright i will try these fixes and get back to you guys, thanks! Share this post Link to post Share on other sites
luxcapere 11 Posted January 12, 2017 4 hours ago, Nikander said: Assuming you want to reference a Variable Name set in attributes of each chopper using the built-in Editor, here is what I would try in the "relevant part of your init" _choppers = [ch1, ch2, ch3, ch4, ch5]; _choppers execVM "Only_Pilots_Fly.sqf"; and then, altering the script that you call using execVM like so { _x addEventHandler ["GetIn", { _vehicle = _this select 0; _seat = _this select 1; _player = _this select 2; _pilotSeats = ["driver", "gunner"]; if (_seat in _pilotSeats) then { if !(_player getVariable ["PlayerCanFly", false]) then { _player action ["eject", _vehicle]; }; }; }]; } forEach _this; I hope this helps this seems to have resolved the initial issue however for some reason, _x throws an error stating "undefined variable in expression _x. I thought _x was a reserved var name that refers to all the members of an array? _x addEventHandler ["GetIn", { Share this post Link to post Share on other sites
luxcapere 11 Posted January 12, 2017 4 hours ago, Nikander said: Assuming you want to reference a Variable Name set in attributes of each chopper using the built-in Editor, here is what I would try in the "relevant part of your init" _choppers = [ch1, ch2, ch3, ch4, ch5]; _choppers execVM "Only_Pilots_Fly.sqf"; and then, altering the script that you call using execVM like so { _x addEventHandler ["GetIn", { _vehicle = _this select 0; _seat = _this select 1; _player = _this select 2; _pilotSeats = ["driver", "gunner"]; if (_seat in _pilotSeats) then { if !(_player getVariable ["PlayerCanFly", false]) then { _player action ["eject", _vehicle]; }; }; }]; } forEach _this; I hope this helps that solved the issue thanks. Now I just need to figure out the new that arose. Ill post here for help if I cant figure it out, thanks again! Share this post Link to post Share on other sites