First of all, your passing unused parameters to your script such as endlogic(which you do not utilize).
Second, you assign global variables to each created unit which prevents further use of the script unless those existing units are first deleted.
Third you have the script running on a continual loop which would only allow it to loop 4 times(12 man per group) had the global variables not been assigned.
Fourth, you fail to send the group on its way once they are created.(Thus the failure to utilize the second parameter.
With that said, I attempted your script as is and nothing happened. So, I reworked it and the script below is a working script which spawns and sends the unit on their way as it should. ;Instructions= place a gamelogic, place a marker called "spawnmarker",. Call like this [groupname,gamelogicname] exec "thisscript.sqs"
;Don't forget to place a uit with the groupname you use before mission start.
_group = _this select 0
_logic = _this select 1
;You could add these additional parameters to pass to the script to prevent from having to use global variables in the createunit command line. Just make sure you replace the below variables(e1,e2,e3) with the following local ones. This will allow you to use one script for each patrol. Don't worry about sending them on their way because once created, they will proceed to the waypoints already assigned to the group name.
;_commander = _this select 2
;_gunner = _this select 3
;_driver = _this select 4
_rtank = ["T72","T80","BMP"]
_r = random (Count _rtank)
_tank = (_rtank select _r - _r mod 1) createVehicle getMarkerPos "SpawnMarker"
_tank lock true
"SoldierECrew" createunit [getMarkerPos "SpawnMarker", _group, "e1 = this; this addeventhandler [{Killed}, {_this exec {deadbody.sqs}}]", 1, "COLONEL"]
~.1
"SoldierECrew" createunit [getMarkerPos "SpawnMarker", _group, "e2 = this; this addeventhandler [{Killed}, {_this exec {deadbody.sqs}}]", 1, "LIEUTENANT"]
~.1
"SoldierECrew" createunit [getMarkerPos "SpawnMarker", _group, "e3 = this; this addeventhandler [{Killed}, {_this exec {deadbody.sqs}}]", 1, "LIEUTENANT"]
e1 moveincommander _tank
e2 moveindriver _tank
e3 moveingunner _tank
e1 setbehaviour "safe"
e1 setspeedMode "FULL"
e2 setspeedMode "FULL"
;This will move the group to the gamelogic passed as the second parameter. Feel free to replace this portion of the
;script with editor inserted waypoints for the appropriate groups.
leader _group domove getpos _logic
~220
goto "LOOP"
exit
The script above can only be used once unless you delete all existing units and then recreate them.
That can be done simply by adding additional code at the start of the script such as.....{_x removealleventhandlers "Killed"} foreach units rb1; {Deletevehicle _x} foreach units rb1
. Not sure but if the units are in a vehicle, you may have to eject them first.
If its going to be for patrol purpose only, go ahead and place two tank units with patrol routes and then place a trigger which checks the alive status of the group that deletes and then executes the above script to replnish the units so that they even if the player destroys the tank, another unit and crew will take its place and continue along its route. That will prevent unneeded numbers from hindering framerate.
The only other thing to work out would be having them react to the player when they(anyone in that group) detects the player and then resetting them once the player has vanished. This can be done using a trigger with the knowsabout command for the group leader to switch their behaviour and then a distance check and knowsabout trigger to reset them.
Hope this helps.