I use this script for respawn AI ennemy units.
;[[E1,E2,E3,E4],100,2,10] exec "Respawn\RespawnUnits.sqs"
; [[array of your groups to respawn], number of total respawn, number mini of the group for start respawn, max number of the squad]
_ArrayGroup = _This select 0
? count _ArrayGroup ==0 : exit
_MaxOfRespawn = _This select 1
? _MaxOfRespawn == 0 : exit
_MiniNumberForRespawn = _This select 2
?_MiniNumberForRespawn > 12 : exit
_SquadDimension = _This select 3
? ((_SquadDimension > 12) or (_SquadDimension == 0)) : exit
_CurrentNumberOfRespawn = 0
#LoopOfRespawn
_i =0
#Ingroup
~.2
_NumberOfCreate = 1
#RespawnUnit
? count units ( _ArrayGroup select _i) >= _SquadDimension : goto "SkipRespawn"
_pos = getPos leader ( _ArrayGroup select _i)
_dir = getDir leader ( _ArrayGroup select _i)
~.5
_dist = -30
_x = (_pos select 0) + _dist * sin _dir
_y = (_pos select 1) + _dist * cos _dir
;nobody globalchat format ["%1, %2,%3",_CurrentNumberOfRespawn,_ArrayGroup select _i, count units ( _ArrayGroup select _i) ]
? _NumberOfCreate ==1 : "SoldierEMG" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==2 : "SoldierELAW" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==3 : "SoldierEMedic" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate ==4 : "SoldierEG" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
? _NumberOfCreate > 4 : "SoldierEB" createUnit [[_x,_y ], _ArrayGroup select _i,"NouvelleUnité = this"]
NouvelleUnité addEventHandler ["Killed", "[_this select 0] exec ""Respawn\RemoveKill.sqs"""]
_CurrentNumberOfRespawn = _CurrentNumberOfRespawn +1
? _CurrentNumberOfRespawn >_MaxOfRespawn : exit
_NumberOfCreate = _NumberOfCreate +1
? count units ( _ArrayGroup select _i) < _SquadDimension : goto "RespawnUnit"
#SkipRespawn
_i = _i + 1
? _i < count _ArrayGroup : goto "Ingroup"
? _CurrentNumberOfRespawn <_MaxOfRespawn : goto "LoopOfRespawn"