Currently llGetAgentList() as an options parameter that is unused and the wiki warns of "possible stack/heap collision errors" because of the potential size of the returned list.
This is like walking on a razors edge and sometimes forces us to use an extra script just to collect data of the parcel, with asynchronous message exchange with the main script, resulting in lots of complications just to
try
to avoid this.
As already suggested in the wiki itself, there is room for improvement to limit the size of the returned list and hence the risk of stack/heap collisions.
My first suggestion is of course to add an option to limit the size of the returned list:
AGENTLIST_MAXNUM, with an integer value, 0 (no limit) being the default.
Then an option to order the list is of course desirable:
AGENTLIST_SORT, with an integer value:
AGENTLIST_SORT_BYDISTANCE : sort agents by distance from the scripted object
AGENTLIST_SORT_BYNAME : sort agents by (legacy) name
AGENTLIST_SORT_BYAGE : sort them by age
(to be completed)
And an associated option to specify the sorting order:
AGENTLIST_SORTINGORDER, with integer value: 0 (default) for ascending, 1 for descending order
Other options to filter the list may also be useful: by minimum aga, by maximum age, by minimum distance, by maximum distance, by payment info .... (and possibly other filters).