Jump to content

Recommended Posts

     {deleteVehicle _x} forEach (units _Ga3);    // WORKS but only for alive units  :(

Share this post


Link to post
Share on other sites
_RBapc = ["B_APC_wheeled_01_cannon_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_ghillie_sard_F","B_soldier_AA_F","B_soldier_AR_F","B_soldier_GL_F"];
_RBtank = ["B_MBT_01_TUSK_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_soldier_AA_F","B_soldier_GL_F" ];  
_RBaaa = ["B_APC_tracked_01_AA_F"];   
_RBcar = ["B_MRAP_01_hmg_F","B_MRAP_01_gmg_F"];  
 
_RBconvoy = selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar] append selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar];

_pos = (getPos Bres1) set [2, 0];

// get unique reative positions in a circle of 20 m around Bres1 (no more random explosions)
_angle_diff = 360 / count _RBconvoy;
_cur_angle = random 360;

_relativePositions = [];
{
 _relativePositions pushBack (_pos getPos[20, _cur_angle]);
 _cur_angle = _cur_angle + _angle_diff;
 true
} count _RBconvoy;

// spawn convoy
_Ga3 = [_pos,WEST,_RBconvoy ,_relativePositions] call BIS_fnc_spawnGroup;

//get all unit and vecs of convoy
_all_men = [];
_all_vec = [];

{
 _all_men pushBackUnique _x;
 
 _vec = objectParent _x;
 if(!isNull _vec) then
 {
  _all_vec pushBackUnique _vec;
  {
   _all_men pushBackUnique _x;
   true
  } count crew vec;
 };
 true
}count units _Ga3;

//get all empty cargo seats of convoy
_all_empty_seats = _all_vec apply 
{
 fullCrew [_x, "cargo", true] params ["_unit", "_role", "_cindex"];
 [_x, _unit, _cindex]
}) select {isNull (_x select 1)};

//move all men in all empty cargo seats
_num_men = count _all_men;

{
 if (_forEachIndex isEqualTo _num_men) exitWith {}; // end loop if all men borded already

 (_all_men select _forEachIndex) moveInCargo [_x select 0, _x select 2];

} forEach _all_empty_seats;



/// DO WHAT EVER U WANT HERE



//Delete all vecs and men of convoy
 {deleteVehicle _x;} count _all_men;
 {deleteVehicle _x;} count _all_vec;

 

Edited by sarogahtyp
corrected something

Share this post


Link to post
Share on other sites

ok this seems to work:

 

Spoiler

// HEAD QUARTERS -- TROOPS 

if (isServer) then {
   while {true} do {

_result_array=[];
      
_RBapc = ["B_APC_wheeled_01_cannon_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_ghillie_sard_F","B_soldier_AA_F","B_soldier_AR_F","B_soldier_GL_F"];
_RBtank = ["B_MBT_01_TUSK_F","B_engineer_F", "B_medic_F", "B_soldier_AT_F","B_soldier_M_F","B_soldier_AA_F","B_soldier_GL_F" ];  
_RBaaa = ["B_APC_tracked_01_AA_F"];   
_RBcar = ["B_MRAP_01_hmg_F","B_MRAP_01_gmg_F"];  
 
_RBconvoy1 = selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar];
_RBconvoy2 = selectRandom [_RBapc, _RBtank, _RBaaa, _RBcar];
_relativePositions = [];
{_relativePositions pushBack [-20 + random 40,-20 + random 40,0]} forEach _RBconvoy1 + _RBconvoy2;
_Ga3 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 1],WEST,_RBconvoy1 + _RBconvoy2,_relativePositions, [], [], [], [], 0,false] call BIS_fnc_spawnGroup;
_Gall = units _Ga3;
  _vehs = vehicles select {driver _x in units _GA3};
  _veh1 = _vehs select 0;
  _veh2 = if (count _vehs > 2) then [{_vehs select 2},{_vehs select 1}];
for "_i" from 0 to count (units _Ga3) - 1 do {
    if (!(((units _GA3) select _i) in _veh1) && !(((units _GA3) select _i) in _veh2)) then {((units _GA3) select _i) moveInCargo _veh1};
    if (!(((units _GA3) select _i) in _veh1)) then {((units _GA3) select _i) moveInCargo _veh2};
};                                                   
      [_Ga3, getPos Darea, 9000] execVM "DDscripts\DHQPatrol.sqf";
      uiSleep 5;
      _Ga3 move (getpos Darea);
      waitUntil {sleep 30;{alive _x && _x in _veh1} count crew _veh1 == 0 || (!canMove _Veh1 || fuel _Veh1 == 0)};                                 
      uiSleep 12;                                                                                                       //120 seconds to let survivors to fight back a bit
      waitUntil {sleep 30;{_veh1 distance2D _x > 10} count allPlayers > 0};                              // wait for to be far from players
                                                    
      {deleteVehicle _x} forEach _vehs;
//      {deleteVehicle _x} forEach (units _Ga3);    // WORKS but only for alive units     
         {deleteVehicle _x} forEach _Gall;                                                                                       
      uiSleep 5; 
      format ["BLUE convoy en route!"] remoteExecCall ["hint"];                                                      
   };
}; 

thanks guys for the teaching!!


EDIT:
Sarogahtyp..you beated me again on time ! thanks man for your help ! i really appreciate !

Share this post


Link to post
Share on other sites

i did not beat u. I scripted a complete other (I bet faster) way to do all those things...

I also bet that u get some random explosions sometimes with ur current script. also it uses too long arrays. As I can't test here so I'm just guessing but I think what I posted in my last post should have faster methods and no explosions because of 2 positions are too close together sometimes (thats what can happen with ur current script).

 

but in it's current state my script could have errors and bugs because it's untested.

Edited by sarogahtyp

Share this post


Link to post
Share on other sites

ahh ! good info !! thanks man, i'm going to test it intensively !!
thanks for your tips !
 

Share this post


Link to post
Share on other sites

ok guys....back to the original script (LOL) !
(the one about create a vehicle, that if destroyed get re-created ecc..)

 

Spoiler

// BLU PLANE 1

if (isServer) then {
  [] spawn {
    while {true} do {
      _grpDveh = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 90],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh;                                                                // now you have an array with these guys (pilot or else)             
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      uiSleep 20;                                                                            // wait some time so crew can die or move away
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL ASAP at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         sleep 600;                                   // wait 600 secs = 10 minutes (6 as test now) TO DELAY RESPAWN TO PUNISH DEATH AND GIVE TIME TO SAVE CREW         
          if ({((_crewdVeh select {alive _x}) select 0) distance2D _x < 50} count allPlayers > 0 ) then 
          {
             {deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol
          } else {format ["BLUE crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh}
      } else {sleep 600; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;
    };
  };
};

 

...ok ..well...right now its works, but i wish to update a bit the "rescue" part.
wish to make crew automatically join same side player that goes to less than 10 meters from crew.
...and make it automatically joins as captive (weapons removed) if a player ofenemy faction approach him from less than 10 meters!
is a plausible thing to do, and more important will be performance friendly ?
thanks for any help ! (i'm still burning my head to find a solution!)

Share this post


Link to post
Share on other sites

i've menaged to put togheter this:
 

{
  if ((side _x) == independent) then
  {
      if (_x distance2D crew1 < 10) then
      {
         [crew1] join _x;
      };
  };
} forEach allUnits;

seems to do its work...now i must elaborate a logic and a script to support the whole idea!

Share this post


Link to post
Share on other sites

"big" progress (well.... for me....)

 

Spoiler

waitUntil {sleep 3;{_x distance crew1 < 10} count allPlayers > 0};     // {_x distance crew1 < 10} count allPlayers > 0

{
  if ((side _x) == independent && isplayer _x) then
  {
      if (_x distance2D crew1 < 10) then
      {
         [crew1] join _x;
      };
  };
} forEach allUnits;


{
  if ((side _x) == west && isplayer _x) then
  {
      if (_x distance2D crew1 < 10) then
      {
         [crew1] join _x;
      };
  };
} forEach allUnits;

 

this makes so that when a player gets near to crew1 (will be replaced once merged into original script) it will discriminate the situation by side A and side B.
i dont know how terminate this anyway after 10 minutes!

Share this post


Link to post
Share on other sites
4 hours ago, sarogahtyp said:

i did not beat u. I scripted a complete other (I bet faster) way to do all those things...

I also bet that u get some random explosions sometimes with ur current script. also it uses too long arrays. As I can't test here so I'm just guessing but I think what I posted in my last post should have faster methods and no explosions because of 2 positions are too close together sometimes (thats what can happen with ur current script).

 

but in it's current state my script could have errors and bugs because it's untested.

 

No that doesn't happen. I tested spawning 3 ,even 4 patrols at the same point, using a repeatable radio A.   The reason is in my use of BIS_fnc_spawnGroup. (Last script, see all params).

You did a good job with your version. Not tested but a different approach is always interesting.
Good luck for endless inputs, making all scripts as mash!

Share this post


Link to post
Share on other sites

GOOD NEWS! i think i made it!!
 


_timeOver = diag_tickTime +5;
waitUntil {sleep 10;{_x distance crew1 < 10} count allPlayers > 0 || diag_tickTime >= _timeOver};
{
  if ((side _x) == independent) then
  {
      if (_x distance2D crew1 < 10) then {[crew1] join _x};
  };
} forEach allplayers;

{
  if ((side _x) == west) then
  {
      if (_x distance2D crew1 < 10) then {[crew1] join _x};
  };
} forEach allplayers;
if (diag_tickTime >= _timeOver) then {hint "time over"};

yeeeah!

Share this post


Link to post
Share on other sites

.....i seriously melted my brain.....
.....anyway i made it! here is the code, for the people of tomorrow:
 

Spoiler

// BLU PLANE 1

if (isServer) then {
  [] spawn {
    while {true} do {
      _grpDveh = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 90],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup; 
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      _Dcrew = _crewDveh select 0; 
      _Dcrew2 = _crewDveh select 1; 
      _Dcrew3 = _crewDveh select 2; 
      _Dcrew4 = _crewDveh select 3;
      {_x setVehicleAmmo 0.1} forEach [_Dcrew,_Dcrew2,_Dcrew3,_Dcrew4];                     // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 2000} count allPlayers > 0};                  // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];

         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;{_x distance _DCrew < 9} count allPlayers > 0 || {_x distance _DCrew2 < 9} count allPlayers > 0 || {_x distance _DCrew3 < 9} count allPlayers > 0 || {_x distance _DCrew4 < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;
    };
  };
};

 

YEAH!

EDITED

Share this post


Link to post
Share on other sites

haha i was too optimist....seems that if the starting crew its less than 4 people, it throws an error...
need some way to adapt it to 1 to 4 crew, or (evil way) kill crew in excess, so there is always only 1 to save.
really need help on this...i already did all that came to my mind!

EDIT:
i'm in the situation where i need two different  _x in same sentence....  kind of :
 { if (_x distance2D _x < 10) then [MYCODE]} forEach _crewDveh;
(where first _x its about allplayers and second _x its about _crewDveh

Share this post


Link to post
Share on other sites

...its a ridicolous brutal approach....i really need help optimizing this....

 

Spoiler

// BLU PLANE 1

if (isServer) then {
  [] spawn {
    while {true} do {
      _grpDveh = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 90],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup; 
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      _Dcrew = _crewDveh select 0;

      _allCrew = count _crewDveh;                                               // returns the number of alive crew units
      if (_allCrew == 1) then { _Dcrew = _crewDveh select 0;

      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;{_x distance _DCrew < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};
      if (_allCrew == 2) then { _Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;

      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;{_x distance _DCrew < 9} count allPlayers > 0 || {_x distance _DCrew2 < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 3) then { _Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;

      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;{_x distance _DCrew < 9} count allPlayers > 0 || {_x distance _DCrew2 < 9} count allPlayers > 0 || {_x distance _DCrew3 < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 4) then { _Dcrew4 = _crewDveh select 3;_Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;

      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;{_x distance _DCrew < 9} count allPlayers > 0 || {_x distance _DCrew2 < 9} count allPlayers > 0 || {_x distance _DCrew3 < 9} count allPlayers > 0 || {_x distance _DCrew4 < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};


    };
  };
};

 

thanks !

EDITED: fixed a typo error

Share this post


Link to post
Share on other sites

i've a problem with a simple condition (right now it activates also if crew to rescue is dead, and i dont want to):

 

 waitUntil {sleep 10;({alive _x} count _crewDveh) > 0;{_x distance _DCrew < 9} count allPlayers > 0 || diag_tickTime >= _timeOver};

i wish condition be like this:
WAITUNTIL (check condition every 10 seconds; there is at least 1 alive crew; the distance between crew and a player is <9);   OR     timer is over;

Share this post


Link to post
Share on other sites

......menaged to get it work with:

waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && ({_x distance _DCrew < 9} count allPlayers) > 0) || diag_tickTime >= _timeOver};


BUT.....i need to use others conditions, like this:
 

waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 &&  ({_x distance _DCrew2 < 9} count allPlayers) > 0))) || diag_tickTime >= _timeOver};

pleasee....help me !

Share this post


Link to post
Share on other sites

// SSSSSSPPLAAAATTT !!! (_brain exploded);

 

Spoiler

// BLU PLANE 1

if (isServer) then {
  [] spawn {
    while {true} do {
      _grpDveh = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 90],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      _Dcrew = _crewDveh select 0;
//_Dveh setFuel 0;                    /////// TO TEST
//_Dveh setdamage 0.95;
//_Dveh allowDamage FALSE;            /////// END TO TEST
      _allCrew = count _crewDveh;                                                            // returns the number of alive crew units

      if (_allCrew == 1) then { _Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                                             // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && (({_x distance _DCrew < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 2) then { _Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 3) then { _Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0; //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0 || ({_x distance _DCrew3 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 4) then { _Dcrew4 = _crewDveh select 3;_Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0 || ({_x distance _DCrew3 < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == west) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Bres1 select 0, (getPos Bres1 select 1) +0, 120],WEST,["B_plane_CAS_01_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == independent) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Gres1 select 0, (getPos Gres1 select 1) +0, 120],INDEPENDENT,["I_plane_fighter_03_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == east) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos Rres1 select 0, (getPos Rres1 select 1) +0, 120],EAST,["O_plane_CAS_02_dynamicLoadout_F"]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

    };
  };
};

 

i cant belive this...but seems to work!

Share this post


Link to post
Share on other sites

...added variables to be able to clone the script for more vehicles!

 

Spoiler

// BLU PLANE 1

if (isServer) then {
  [] spawn {
    while {true} do {
      _Dtype = "B_plane_CAS_01_dynamicLoadout_F";
      _DtEN = "O_plane_CAS_02_dynamicLoadout_F";
      _DtGR = "I_plane_fighter_03_dynamicLoadout_F";
      _Dres = Bres1;
      _DrEN = Rres1;
      _DrGR = Gres1;
      _Dside = WEST;
      _DsEN = EAST;
      _DsGR = INDEPENDENT;      
      _grpDveh = [[ getPos _Dres select 0, (getPos _Dres select 1) +0, 90],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      _Dcrew = _crewDveh select 0;
//_Dveh setFuel 0;                    /////// TO TEST
//_Dveh setdamage 0.95;
//_Dveh allowDamage FALSE;            /////// END TO TEST
      _allCrew = count _crewDveh;                                                            // returns the number of alive crew units

      if (_allCrew == 1) then { _Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                                             // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && (({_x distance _DCrew < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == _Dside) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _Dres select 0, (getPos _Dres select 1) +0, 120],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsGR) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrGR select 0, (getPos _DrGR select 1) +0, 120],_DsGR,[_DtGR]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsEN) then
           {
               if (_x distance2D _DCrew < 10) then {[_Dcrew] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrEN select 0, (getPos _DrEN select 1) +0, 120],_DsEN,[_DtEN]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 2) then { _Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == _Dside) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _Dres select 0, (getPos _Dres select 1) +0, 120],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsGR) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrGR select 0, (getPos _DrGR select 1) +0, 120],_DsGR,[_DtGR]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsEN) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10) then {[_Dcrew, _Dcrew2] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrEN select 0, (getPos _DrEN select 1) +0, 120],_DsEN,[_DtEN]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 3) then { _Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0; //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0 || ({_x distance _DCrew3 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == _Dside) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _Dres select 0, (getPos _Dres select 1) +0, 120],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsGR) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrGR select 0, (getPos _DrGR select 1) +0, 120],_DsGR,[_DtGR]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsEN) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrEN select 0, (getPos _DrEN select 1) +0, 120],_DsEN,[_DtEN]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

      if (_allCrew == 4) then { _Dcrew4 = _crewDveh select 3;_Dcrew3 = _crewDveh select 2;_Dcrew2 = _crewDveh select 1;_Dcrew = _crewDveh select 0;  //IF //////////////////////////////////////////////////////////////////////////////////////////////////////////
      {_x setVehicleAmmo 0.1} forEach _crewDveh;                      // give few ammo to the poor crew    
      [_grpDveh, getPos Darea, 9000] call BIS_fnc_taskPatrol;
      waitUntil {sleep 30;{alive _x && _x in _Dveh} count crew _Dveh == 0 || (!canMove _dVeh || fuel _dVeh == 0 || !someAmmo _dveh)};  
//      waitUntil {sleep 30;{_x distance _Dveh > 20} count allPlayers > 0};                // CHANGE WITH A SLEEP//////////// DA RIVEDERE !!!!!!!!!!!!!!!!
      uiSleep 60;                                                                            // wait some time so crew can die or move away
      {deleteVehicle _x} forEach crew _Dveh;                                                 // delete crew first in case Dveh cannot move
//      {deleteVehicle _x} forEach _crewDveh;     // WORKS TOO
      deletevehicle _Dveh;                                                                   // Dveh is empty OR cannot move...better delete it
      _aliveCrew = {alive _x} count _crewDveh;                                               // returns the number of alive crew units
      if (_aliveCrew > 0) then 
      {
         format ["BLUE crew need EXFIL in 10 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +606;
         waitUntil {sleep 10;(({alive _x} count _crewDveh > 0) && (({_x distance _DCrew < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0 || ({_x distance _DCrew3 < 9} count allPlayers) > 0 || ({_x distance _DCrew2 < 9} count allPlayers) > 0)) || diag_tickTime >= _timeOver};
         {
           if ((side _x) == _Dside) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew is safe! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _Dres select 0, (getPos _Dres select 1) +0, 120],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsGR) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by GREEN! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrGR select 0, (getPos _DrGR select 1) +0, 120],_DsGR,[_DtGR]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;
         {
           if ((side _x) == _DsEN) then
           {
               if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {[_Dcrew, _Dcrew2, _Dcrew3, _Dcrew4] join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;format ["BLUE crew was captured by RED! extra vehicle en route!"] remoteExecCall ["hint"];_grpDveh2 = [[ getPos _DrEN select 0, (getPos _DrEN select 1) +0, 120],_DsEN,[_DtEN]] call BIS_fnc_spawnGroup;[_grpDveh2, getPos Darea, 9000] call BIS_fnc_taskPatrol};
           };
         } forEach allplayers;

         if (diag_tickTime >= _timeOver) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh};

      } else {sleep 360; {deleteVehicle _x} forEach _crewDveh};
      uiSleep 6;};

    };
  };
};

 

 

Share this post


Link to post
Share on other sites

hello guys!

was streamlining a bit this really ugly script....i've encountered the major problem here:
 

if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {...my code bla bla bla...

the problem is that there can be 1 to 4 crew members (_Dcrew, _Dcrew2 _Dcrew3, _Dcrew4), and i wish that any player (_x) who get at a distance of 10 meters from any crew member can capture the whole crew group.
i somehow need to use the _x variable two times for different subjects (dont seem to exist an _y variable, right ?) or ....really dunno how do this whitout repeat code, but i'm sure there is a way!
just point me in the right direction please!
thanks!

Share this post


Link to post
Share on other sites
5 minutes ago, dlegion said:

hello guys!

was streamlining a bit this really ugly script....i've encountered the major problem here:
 


if (_x distance2D _DCrew < 10 || _x distance2D _DCrew2 < 10 || _x distance2D _DCrew3 < 10 || _x distance2D _DCrew4 < 10) then {...my code bla bla bla...

the problem is that there can be 1 to 4 crew members (_Dcrew, _Dcrew2 _Dcrew3, _Dcrew4), and i wish that any player (_x) who get at a distance of 10 meters from any crew member can capture the whole crew group.
i somehow need to use the _x variable two times for different subjects (dont seem to exist an _y variable, right ?) or ....really dunno how do this whitout repeat code, but i'm sure there is a way!
just point me in the right direction please!
thanks!

 

_unit = player or whatever;
if ({_unit distance2D _x < 10} count [_DCrew1,_DCrew2,DCrew3] >= 1) then {hint "success!"};

Cheers

Share this post


Link to post
Share on other sites

...i feel that stupid when solution was so simple!
really thanks man !!

Share this post


Link to post
Share on other sites

i'm melting by tring to make this work. re-readed BIKI on all commands being used, but there is something escaping from my sight.
now error is "4 elements provided, 3 expected", but i suppose thats not the point...
 

_crewDveh = crew _Dveh;          // i already defined an array with crew members 

 waitUntil {sleep 10;(({alive _x} count _crewDveh) > 0 && ({_crewDveh distance2D _x < 10} count allPlayers) >= 1) || diag_tickTime >= _timeOver};

the goal is to waitUntil  ANY alive player gets near (less than 10 meters) to ANY of the still alive crew members.
i'm really sorry but i cant get out of this one :(
thanks!

Share this post


Link to post
Share on other sites

crewDveh is an array of objects...

can distance2D be used with such an array?

Share this post


Link to post
Share on other sites

...distance (and distance2d) accept arrays, or i misunderstood it ?

 

waituntil {allplayers distance _crewDveh};

i'm trying this right now....

Share this post


Link to post
Share on other sites

sorry but i've no idea what that mean man!
 

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

×