and then run this script from init.sqf:
_active = true;
while {_active} do
{
if (wave == 5) then//means a maximum number of waves is 4
{
_active = false;
}
else
{
_countAlive = 0;
_actualEnemyGroup = missionNamespace getVariable [format["wave%1", wave], 1];
{
if (alive _x) then
{
_countAlive = _countAlive + 1;
};
}
forEach (units _actualEnemyGroup);
if (_countAlive == 0) then
{
wave = wave + 1;
};
};
sleep 1;
};
sleep ((random 5)+5);
["end1", true, true] call BIS_fnc_endMission;