A better way to wave respawn?

Thanks to IM SORRY BUFFALO on an old steam thread: https://steamcommunity.com/app/107410/discussions/17/135507548125694052/

Also thanks to commy2 the sole respondent.

This is the script that has come to Fruition:

In the init.sqf

playersInMission = 0;

setPlayerRespawnTime 720;

In a file called serverControl.sqf

 playersInMission = {isPlayer _x && alive _x} count playableUnits; 

  if (playersInMission < 1) then 

   { 

    setPlayerRespawnTime 3; 

   }; 

    Sleep 5;

    setPlayerRespawnTime 720;

In a file called OnPlayerKilled.sqf

execVM "serverControl.sqf";

So I am by NO means a good scripter there is probably a MUCH better way to do it but this is what I came to. so the spawn time is set intially to 12 minutes and the variable playersInMission is set to 0 and whenever a player is killed it will do a count, if the count is less than X (in this testing case 1) then the player respawn time will be set to 3 seconds the script will wait for 5 seconds and then reset the spawn time to 12 minutes. I will probably set the 12 minutes to something ridiculously high but this is for testing purposes right now. Any feedback or insight is appreciated.

/r/armadev Thread