Jump to content
Sign in to follow this  
II OMEGA101 II

[Solved] Deleting a group when at a distance from player

Recommended Posts

Hi peeps,

 

  I'm writing a script (cut and pasted from various other scripts) that spawns units while a player is inside the marker. I would like them to be deleted when the player has either moved outside the marker or moved a certain distance away. I have tried different methods and functions however they either throw errors or don't work as intended. One method that does delete the group will not work when the player moves outside the hot zone. I am a scripting noobie. Would anyone kindly be able to provide some advice please? Once the basic functionality is working I would like to expand this script much more.

 

if (isServer) then {
_Spawntarget = player;
_Spawndistance = 100;
_deleteDist = 150;
_patrolDist = 500;
_Spawngroups = [
(configfile >> "CfgGroups" >> "East" >> "rhs_faction_vdv" >> "rhs_group_rus_vdv_infantry" >> "rhs_group_rus_vdv_infantry_squad")
];

_Spawnmaxdelay =40;
_Spawnavgdelay =50;
_Spawnmindelay =60;
_Spawnside = OPFOR;



while {true} do {

   if (_Spawntarget inArea "HotZone_1") then {
       _SpawnPosistion = _Spawntarget getRelPos [_Spawndistance, round random 360];
       _NewGroup = [_SpawnPosistion, _Spawnside , _Spawngroups select (floor (random (count _Spawngroups)))] call BIS_fnc_spawnGroup;
	   [_NewGroup, position leader _Spawntarget, _patrolDist] call bis_fnc_taskpatrol;
	   systemChat "HotZone_1 Working";
    };

	if (_Spawntarget inArea "HotZone_2") then {
       _SpawnPosistion = _Spawntarget getRelPos [_Spawndistance, round random 360];
       _NewGroup = [_SpawnPosistion, _Spawnside , _Spawngroups select (floor (random (count _Spawngroups)))] call BIS_fnc_spawnGroup;
	   [_NewGroup, position leader _Spawntarget, _patrolDist] call bis_fnc_taskpatrol;
	   systemChat "HotZone_2 Working"; 
    };
		if ((_Spawntarget distance (units _NewGroup)) >= _deleteDist) then
		{
			{deletevehicle _x} forEach (units _NewGroup);
		};   
	
	   sleep (random [_Spawnmindelay,_Spawnavgdelay,_Spawnmaxdelay]);		
  };
};

 

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
Sign in to follow this  

×