bumyplum 10 Posted November 25, 2018 I'm trying to make a script where it executes a code on the driver of the vehicle your in, this is what i have (player setdamage 1; is just to test if it works) { if !(player == vehicle player) then { if((driver (vehicle player)) isEqualTo player) then {player setdamage 1} else {} } } forEach ((getPosATL player) nearEntities [["Man"],100]); I'm trying to run the script on all drivers within 100m of the play but it doesn't seem to work Share this post Link to post Share on other sites
davidoss 550 Posted November 25, 2018 { if (!isnull (objectParent _x)) then { _driver = (driver (vehicle _x)); if (_driver isEqualTo _x) then { _x setdamage 1; }; }; } forEach ((getPosATL player) nearEntities [["Man"],100]); Share this post Link to post Share on other sites
bumyplum 10 Posted November 25, 2018 6 minutes ago, davidoss said: { if (!isnull (objectParent _x)) then { _driver = (driver (vehicle _x)); if (_driver isEqualTo _x) then { _x setdamage 1; }; }; } forEach ((getPosATL player) nearEntities [["Man"],100]); This doesn't seem to work Share this post Link to post Share on other sites
davidoss 550 Posted November 25, 2018 what you want to achieve exactly?? Share this post Link to post Share on other sites
bumyplum 10 Posted November 25, 2018 To eject only the vehicle drivers within 100m Share this post Link to post Share on other sites
davidoss 550 Posted November 25, 2018 [] spawn { private _list = (ASLToAGL (getPosASL player)) nearEntities [["Air", "LandVehicle", "Ship"], 100]; { private _driver = (driver _x); if (!isnil "_driver") then { if (local _driver) then { if ((velocity _x) isEqualTo [0,0,0]) then { _driver action ["getOut", _x]; } else { _driver action ["Eject", _x]; }; } else { 0 = [_driver, { params[ ["_object",objNull,[objNull]] ]; _object setVariable ["my_owner",owner _object,true]; }] remoteExecCall ["bis_fnc_call", 2]; waitUntil {sleep 1; !isnil {_driver getVariable "my_owner"} || !alive _driver}; if (!alive _driver) exitWith {}; if ((velocity _x) isEqualTo [0,0,0]) then { 0 = [_driver, ["getOut", _x]] remoteExecCall ["action",(_driver getVariable "my_owner"),false]; } else { 0 = [_driver, ["Eject", _x]] remoteExecCall ["action",(_driver getVariable "my_owner"),false]; }; }; }; } forEach (_list select {((getNumber (configFile >> "CfgVehicles" >> typeOf _x >> "hasDriver")) isEqualTo 1) && {!((crew _x) isEqualTo [])}}); }; 1 1 Share this post Link to post Share on other sites
HazJ 1288 Posted November 26, 2018 @davidoss Why so much code? Simplified version: // tested in debug with multiple vehicles [] spawn { _drivers = allUnits select {alive _x && (driver vehicle _x) isEqualTo _x}; { [_x] remoteExec ["moveOut", [0, -2] select isDedicated, FALSE]; } forEach _drivers; }; // apply only to those inside marker named playArea [] spawn { _drivers = allUnits select {alive _x && (driver vehicle _x) isEqualTo _x && _x inArea "playArea"}; { [_x] remoteExec ["moveOut", [0, -2] select isDedicated, FALSE]; } forEach _drivers; }; Adjust condition in _drivers accordingly. 1 Share this post Link to post Share on other sites
davidoss 550 Posted November 26, 2018 Quote Why so much code? Its because Thread author does not supplied any detailed information.My snippet implicates all vehicles types and deliberate vehicles speed. For example: action eject will not work if vehicle is a plane and parking hot Share this post Link to post Share on other sites
HazJ 1288 Posted November 26, 2018 Yeah I understand that but look at my snippet. You have a lot of additional stuff like setVariable, etc and multiple other checks. I am not having a pick or anything - Just trying understand other people's logic / way of thinking if that makes sense? Also was just wondering if there were any specific reasons you did that approach. Why check speed and all that only to eject / force them out anyway? Eject works if no speed. Anyway, all good! Share this post Link to post Share on other sites
davidoss 550 Posted November 26, 2018 Quote Eject works if no speed. Not on planes.Tested Quote Just trying understand other people's logic / way of thinking if that makes sense? Also was just wondering if there were any specific reasons you did that approach. Actions works only if unit is local, sure you can remoteexec it to everybody and at least some client/server will successfully perform it according where is the unit local, but i prefer precise sniper shot instead shot from pellets. Share this post Link to post Share on other sites
bumyplum 10 Posted November 26, 2018 14 hours ago, HazJ said: @davidoss Why so much code? Simplified version: // tested in debug with multiple vehicles [] spawn { _drivers = allUnits select {alive _x && (driver vehicle _x) isEqualTo _x}; { [_x] remoteExec ["moveOut", [0, -2] select isDedicated, FALSE]; } forEach _drivers; }; // apply only to those inside marker named playArea [] spawn { _drivers = allUnits select {alive _x && (driver vehicle _x) isEqualTo _x && _x inArea "playArea"}; { [_x] remoteExec ["moveOut", [0, -2] select isDedicated, FALSE]; } forEach _drivers; }; Adjust condition in _drivers accordingly. From david's code, thanks for the code btw, i've shortened it to my self. [] spawn { _list = (ASLToAGL (getPosASL player)) nearEntities [["Air", "LandVehicle", "Ship", "Man"], 100]; { _driver = (driver _x); _driver action ["Eject", _x] } forEach (_list select {((getNumber (configFile >> "CfgVehicles" >> typeOf _x >> "hasDriver")) isEqualTo 1) && {!((crew _x) isEqualTo [])}}); }; Share this post Link to post Share on other sites