Two things:
first, to answer your question... this would solve your problem:
CreateTimeTrigger(1,
0,2000,3000,"CreateTanks");
CreateTimeTrigger(1,
0,4000,"Attack");
The second param in any trigger determines wether it will be fired once (1) or continuously (0).
...if not for the next thing: (sorry)
Your code will work fine on the first run: the group will be created, and after timetrigger "Attack" fires, they will be set to attack-mode. However, ...
Timer 1 fires after 20~30 marks. Timer 2 fires after precisely 40 marks (so,,, 10~20 later). Once Timer 1 has fired, it will again start counting, and fire at the same interval again (20~30 marks later) and it will de-synchronise with Timer2.
Example: when you create the "CreateTanks" timer, OP2 sets an exact time, for example 2500 ticks (could be anything between 2000~3000 btw). So: Timer1 fies at mark 35 and timer2 at mark 40.
The next time the tiemr1 (CreateTanks) fires is at mark 50. The second time that timer2 fires is at mark 80.
Now you get what i'm saying ?
The other is: you keep creating new groups, without destroying them. Outpost has 127 ScStubs for you to use. Each timer or group is 1 stub. If you want it to work the way u want, you should add DeleteWhenEmpty(1) to your group, which lets op2 delete the group you've created once all those units in that specific group are dead, freeing up the stub.
Still this won't solve the desync.
In order to solve that, you need to change the code to something like this:
SCRIPT_API void CreateTanks()
{
Unit u;
grp1=CreateFightGroup(Player[1]);
grp1.SetRect(MAP_RECT(30,8,34,12));
TethysGame::CreateUnit(u,mapLynx,LOCATION(158,2),1,mapMicrowave,SouthWest);
grp1.TakeUnit(u);
TethysGame::CreateUnit(u,mapLynx,LOCATION(158,4),1,mapMicrowave,SouthWest);
grp1.TakeUnit(u);
grp1.SetDeleteWhenEmpty(1);
CreateTimeTrigger(1,1,1000,"Attack");
}
This time, make sure the 2nd param of the trigger is 1, since this trigger only needs to fire once for this particular group.
I hope this helps, although i'm unsure if it solves the problem 100%. it may still crash in the long run