// Replace OBJECT_SELF if not appropriate in the context. Note that
// the area's tag is used, so the waypoints tag would have to look like this, using
// the example of post #1: "MOB_" + tag of area + 1 and upper
string sTag = "MOB_" + GetTag(GetArea(OBJECT_SELF)); // retrieve area any which way you want
int nNth = 1;
object oWP = GetObjectByTag(sTag+IntToString(nNth));
while(oWP != OBJECT_INVALID)
{
CreateObject(OBJECT_TYPE_CREATURE, mob, GetLocation(oWP));
oWP = GetObjectByTag(sTag+IntToString(++nNth));
}
This way you can have your waypoints numbered and quickly retrieve only those within the specified area. The code can be called from anywhere and does not perform distance checks in the loop.
EDIT: Fixed an oversight, thanks to Proleric.
Kato