Thank you for the explanation Cthulu!
I already knew about for-loops in general, but extra knowledge is always good.
I used the help I got to create this script:
int Spawn_PickUnusedNumber(string &in asName, int alFrom, int alTo)
{
int Start = RandInt(alFrom,alTo);
int End = alTo;
for(int i=Start;i<=End;i++)
{
if(GetLocalVarInt(asName+i) == 0)
{
return int(i);
}
}
return int(-1);
}
The idea is, I have a set of enemies. When one is spawned it's variable is set to 1. This is so that it cannot be picked while it is already active.
This Spawn_PickUnusedNumber helps me pick a number that isn't already used. If all numbers are used it'll set the number to -1, and thus...
if(iEnemy == -1)
{
AddDebugMessage("ENEMY NOT FOUND", false);
return;
}
...ignores this spawn.
Trying is the first step to success.