Jump to content

Recommended Posts

i should give him an array of "posiotions" ?

Share this post


Link to post
Share on other sites
waituntil {({getpos _x} foreach allplayers) distance ({getpos _x} foreach _crewDveh) < 10};

something like this ?

EDIt:
seems to kinda work....will update....

Share this post


Link to post
Share on other sites

u can pass an object and the engine will determine its position to calculate the distance or

u pass a position array (3D or 2D) like [5464.44, 952.12, 13] or like [33.5, 66.4] and the engine uses it for distance calculation.

 

but if u pass an array of objects ... that's just nonsense.

Share this post


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

waituntil {({getpos _x} foreach allplayers) distance ({getpos _x} foreach _crewDveh) < 10};

something like this ?

it's getting weird and weirder...

 

what does

({getpos _x} foreach allplayers)

return? Nothing. so u pass nothing to distance... just can't work.
distance needs an object or a position...

Share this post


Link to post
Share on other sites

heh...i have to really thank you, without that info i would have never found the way out of the tunnel !!

Share this post


Link to post
Share on other sites

ah....ok....seeing no error i supposed it was kinda working...lol

Share this post


Link to post
Share on other sites

i'm sorry but i really need a more concrete help on this, i cant get the problem, and for sure its solution.

Share this post


Link to post
Share on other sites
1 minute ago, dlegion said:

ah....ok....seeing no error i supposed it was kinda working...lol

u r crazy ... with which code? the latest aove? can't work. I told u.

Share this post


Link to post
Share on other sites

if u ask every minute then i ve no time to write a solution for it^^

  • Like 1

Share this post


Link to post
Share on other sites
waitUntil
{
 sleep 10;
   {alive _x} count _crewDveh > 0 &&
	{
 	 _plyr = _x;
 	 _near = false;
 	 {
  	  if (_plyr distance2D _x < 10) exitWith {_near = true};
  	  true
 	 } count _crewDveh;
 	 _near
	} count allPlayers > 0
};

try!

Share this post


Link to post
Share on other sites

wow ! really nice, you created a variable system...good idea! going to try it now !
thanks!

Share this post


Link to post
Share on other sites

it works perfectly !
you pulled me out of this painful headhache !!
thanks man !!! huge thanks !

Share this post


Link to post
Share on other sites

But if u check the distance to crew members.... Why not just checking distance to the vehicle only?

sent from mobile using Tapatalk

Share this post


Link to post
Share on other sites

ook, thanks @sarogahtyp , the final script is here:
 

Spoiler

if (isServer) then {
  [] spawn {
    while {true} do {

      _Dtype = "B_heli_transport_01_F";
      _DtEN = "O_heli_light_02_dynamicLoadout_F";
      _DtGR = "I_heli_light_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, 50],_Dside,[_Dtype]] call BIS_fnc_spawnGroup;
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      _Dcrew = _crewDveh select 0;
      {_x setVehicleAmmo 0.1} forEach _crewDveh;
//_Dveh setFuel 0;                    /////// TO TEST
//_Dveh setdamage 0.95;
//_Dveh allowDamage FALSE;            /////// END TO TEST
 
      [_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)};
      _near = false;                // define variable for last IF (M.I.A.)
      uiSleep 60;                                            // give time to survive or die

      if ({alive _x} count _crewDveh > 0) then 
      {
         {_x forceWalk true;} forEach _crewDveh;             // disable run
         format ["BLUE crew need EXFIL in 12 minutes at %1",mapGridPosition ((_crewdVeh select {alive _x}) select 0)] remoteExecCall ["hint"];
         _timeOver = diag_tickTime +730;                     // 12 minutes to rescue

         waitUntil{sleep 10;({alive _x} count _crewDveh > 0 && {_plyr = _x;_near = false;{if (_plyr distance2D _x < 10) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0) || diag_tickTime >= _timeOver};
         
         {
           if ((side _x) == _Dside) then
           {
               if ({alive _x} count _crewDveh > 0 && {_plyr = _x;_near = false;{if (_plyr distance2D _x < 10) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0) then {_crewDveh join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;deletevehicle _Dveh;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 ({alive _x} count _crewDveh > 0 && {_plyr = _x;_near = false;{if (_plyr distance2D _x < 10) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0) then {_crewDveh join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;deletevehicle _Dveh;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 ({alive _x} count _crewDveh > 0 && {_plyr = _x;_near = false;{if (_plyr distance2D _x < 10) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0) then {_crewDveh join _x;sleep 30;{deleteVehicle _x} forEach _crewDveh;deletevehicle _Dveh;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 && !_near) then {format ["BLU crew declared M.I.A."] remoteExecCall ["hint"]; {deleteVehicle _x} forEach _crewDveh;deletevehicle _Dveh};

      } else {sleep 300; {deleteVehicle _x} forEach _crewDveh;deletevehicle _Dveh};
      uiSleep 6;
      
    };
  };
};

 

hope it will help for future refence!
thanks!

---- EDIT ----
(changed last IF statement...using the _near variable to not overlap)

Share this post


Link to post
Share on other sites

hello again !
...right now i'm trying to make a quite simple script, objective is to have the simplest possible "bubble generic spawner" script!
i'm working hard on it since yesterday....but all i was able to make it work is this:

Spoiler

if (isServer) then {
  [] spawn {
    while {true} do {

      _maxDist = 2000;
      _minDist = 300;
      _Dside = WEST;
      _Dtype = "B_heli_transport_01_F";
      _Darea = [getPos player, _minDist, _maxDist, 12, 0, 10, 0] call BIS_fnc_findSafePos;
      _grpDveh = [_Darea,_Dside,[_Dtype]] call BIS_fnc_spawnGroup;
      [_grpDveh, _Darea, 9000] call BIS_fnc_taskPatrol;
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      HINT "SPAWNED";
      waitUntil{sleep 10;{_plyr = _x;_near = false;{if (_plyr distance2D _x > _maxDist) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0 || !canMove _Dveh};
      {deleteVehicle _x} forEach _crewDveh;
      deletevehicle _Dveh;
      HINT "DELETED";
      uiSleep 4;      
      
    };
  };
};

 

it works (in SP)....but i should make a script for every single unit i wish to spawn....seems not very optimized...  :)
plus...i wish to count "all alive players" as reference points (_Darea right now is SP player position, i wish to make it working for all alive MP players),  and an init for the spawned units, so for example i can use "BIS_fnc_taskPatrol" to give them waypoints, or other commands if needed (like mines).
thanks for any help guys !

Share this post


Link to post
Share on other sites

....searching a way to consider all MP players positions...

Spoiler

if (isServer) then {
  [] spawn {
    while {true} do {

      _maxDist = 2000;
      _minDist = 300;
      _Dside = WEST;
//      _Dtype = "B_heli_transport_01_F";
      _Dtype = "I_boat_armed_01_minigun_F";
      _allPlayerPositionsTemp = [];
	{
                     if (isPlayer _x) then {
					_pos = position vehicle _x;
					_allPlayerPositionsTemp = _allPlayerPositionsTemp + [[_pos]];			
                     };
	} foreach (playableUnits);
//      _Darea = [getPos player, _minDist, _maxDist, 12, 0, 10, 0] call BIS_fnc_findSafePos;        // 0 = land only  1=waterORland 2=water only 
      _Darea = [_allPlayerPositionsTemp, _minDist, _maxDist, 12, 2, 10, 0] call BIS_fnc_findSafePos;        // 2 = on water
      _grpDveh = [_Darea,_Dside,[_Dtype]] call BIS_fnc_spawnGroup;
//      [_grpDveh, _Darea, 9000] call BIS_fnc_taskPatrol;
      [_grpDveh, _Darea, 3000] execVM "DDscripts\DwaterPatrol.sqf";
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      HINT "SPAWNED";
      waitUntil{sleep 10;{_plyr = _x;_near = false;{if (_plyr distance2D _x > _maxDist) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0 || !canMove _Dveh};
      {deleteVehicle _x} forEach _crewDveh;
      deletevehicle _Dveh;
      HINT "DELETED";
      uiSleep 5;      
      
    };
  };
};

 


it works in SP, but in MP give an error in "fnc_findSafePos" line 130...here the image:
https://ibb.co/iW6VSF

Share this post


Link to post
Share on other sites

Just curious but, why do you uiSleep instead of sleep? Also, from what I can see... You don't even need that either...? I personally use:

if ((isDedicated) || (!hasInterface)) exitWith {};

Dedicated server or Headless Client.

Share this post


Link to post
Share on other sites

hem....sorry for my ignorance...i admit i use sleep or uiSleep as the same. i readed the biki, but cant understand the real difference! should i use normal "sleep"?
i'm not sure to understand the second part of you comment...after "IF".
sry :(

Share this post


Link to post
Share on other sites

....if i run script BEFORE respawn...it gives no error....if i wait to start it when i'm alive, it give error...

EDIT: more tests:
when i'm dead, script runs with no error in MP, while when i'm alive it returns the error!! i use "respawn on custom position" as respawn method.
please help me, its driving me mad!!

Share this post


Link to post
Share on other sites

Can you please post the latest full script you currently have so far? Also, I don't think you need to use sleep at all. Oh and, I don't read the thread properly, I have only just realised there's more than one page. LOL

Share this post


Link to post
Share on other sites

sure! thanks for the help !
 

Spoiler

if (isServer) then {
  [] spawn {
    while {true} do {
      uiSleep 5;    
      _maxDist = 2000;
      _minDist = 300;
      _Dside = WEST;
      _Dtype = "I_boat_armed_01_minigun_F";
      _allPlayerPositionsTemp = [];
			{
					//_pos = position vehicle _x;
                                          _pos = getPosASL vehicle _x;
					_allPlayerPositionsTemp = _allPlayerPositionsTemp + [[_pos]];
			} foreach (playableUnits);
		
//      _Darea = [getPos player, _minDist, _maxDist, 12, 0, 10, 0] call BIS_fnc_findSafePos;        // 0 = land only  1=waterORland 2=water only 
      _Darea = [_allPlayerPositionsTemp, _minDist, _maxDist, 12, 2, 10, 0] call BIS_fnc_findSafePos;        // 2 = on water
      _grpDveh = [_Darea,_Dside,[_Dtype]] call BIS_fnc_spawnGroup;
//      [_grpDveh, _Darea, 9000] call BIS_fnc_taskPatrol;
      [_grpDveh, _Darea, 3000] execVM "DDscripts\DwaterPatrol.sqf";
      _Dveh = vehicle leader _grpDveh;
      _crewDveh = crew _Dveh; 
      HINT "SPAWNED";
      waitUntil{sleep 10;{_plyr = _x;_near = false;{if (_plyr distance2D _x > _maxDist) exitWith {_near = true};true} count _crewDveh;_near} count allPlayers > 0 || !canMove _Dveh};
      {deleteVehicle _x} forEach _crewDveh;
      deletevehicle _Dveh;
      HINT "DELETED";
      uiSleep 5;      
      
    };
  };
};

 

EDIT:
anyway dont seem a problem related to sleep...seems more like some kind of trouble between "respawn on custom position" and the "fnc_findSafePos" ...or maybe the code to store positions...i really dont know!

Share this post


Link to post
Share on other sites

I am going to help you clean your code up a bit but first, what are you trying to do exactly? From what I can gather... You spawn a boat and water patrol then delete them all when no players are within the max distance? I don't understand why you are using a while-loop along with other things like spawn as I don't see it is needed unless what you have shown isn't the full script? Are you using while-loop to activate them again when they are within min distance? I assume you are. Kind of like AI caching? Please confirm and let me know. Thanks.

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

×