I have this script I use to create units one the fly for MP coop missions. The script for the more the most part works and creates units once a trigger is activated. However in MP it always creates 12 units even when I specify 4. In the editor it just creates 4 as intented. Also this script causes the occasional lag when 12 dudes pop out of no where.
Is there something I can do to improve the script?
;pos1 being an object (like a rock or barrel)
pos = getpos pos1
; number of units to create
unitnum=8
intel=1
a=0
newgroup=group1
#countloop
; Start Counting
a = a + 1
; if a = unitnum then end script
? a == unitnum : goto "stopscript"
; Create the Solider
"SoldierEMG" createUnit [pos, newgroup,"",intel,"SERGEANT"]
a = a + 1
? a == unitnum : goto "stopscript"
"SoldierELAW" createUnit [pos, newgroup,"",intel,"CAPTAIN"]
a = a + 1
; if a = _unitnum then end script
? a == unitnum : goto "stopscript"
"SoldierEG" createUnit [pos, newgroup,"",intel,"LIEUTENANT"]
a = a + 1
; if _a = _unitnum then end script
? a == unitnum : goto "stopscript"
"SoldierESaboteurPipeHG" createUnit [pos, newgroup,"",intel,"LIEUTENANT"]
goto "countloop"
#stopscript
exit