function
Function syntax
list llGetAgentList(integer scope,// Scope flag (AGENT_LIST_PARCEL,AGENT_LIST_PARCEL_OWNER, orAGENT_LIST_REGION) to filter the returned agents. Values: AgentListScopelist options// A list of options to apply (currently unused).
);- Returns
list- Energy
- 10
Requests a list of agents currently in the region, limited by the scope parameter.
Returns a list [key id0, key id1, ..., key idn] or [string error_msg] - returns avatar keys for all agents in the region limited to the area(s) specified by scope
list result = llGetAgentList(0, []);Caveats
Section titled “Caveats”- There is no guaranteed understandable order or randomness to the list returned.
- Will only return up to 100 agents.
- Ghosts, agents that leave behind a corrupted presence and agents in God Mode depending on the level will have
NULL_KEYreturned instead of their real key withllGetAgentList(). There is also an issue with a certain type of ghosted agent still returning a key too. Perhaps check each key againstllGetAgentSize() to verify if they’re really in the sim or not; none of the above anomalies affectllGetAgentSize().
Examples
Section titled “Examples”Example 1
//Displays up to 100 avatar key: name pairs detected in the entire region
default{ touch_start(integer total_number) { list avatarsInRegion = llGetAgentList(AGENT_LIST_REGION, []); integer numOfAvatars = llGetListLength(avatarsInRegion);
18 collapsed lines
// if no avatars, abort avatar listing process and give a short notice if (!numOfAvatars) { llOwnerSay("No avatars found within the region!"); return; }
integer index; while (index < numOfAvatars) { key id = llList2Key(avatarsInRegion, index); string name = llKey2Name(id);
llOwnerSay(name + " [ " + (string)id + " ]"); ++index; } }}Example 2
5 collapsed lines
// Orders new list based on distance// and returns names and distances on touch
default{ touch_start(integer num_detected) { list keys = llGetAgentList(AGENT_LIST_REGION, []); integer numberOfKeys = llGetListLength(keys);
20 collapsed lines
vector currentPos = llGetPos(); list newkeys; key thisAvKey;
integer i; for (i = 0; i < numberOfKeys; ++i) { thisAvKey = llList2Key(keys,i); newkeys += [llRound(llVecDist(currentPos, llList2Vector(llGetObjectDetails(thisAvKey, [OBJECT_POS]), 0))), thisAvKey]; }
newkeys = llListSort(newkeys, 2, FALSE); // sort strided list by descending distance
for (i = 0; i < (numberOfKeys * 2); i += 2) { llOwnerSay(llGetDisplayName(llList2Key(newkeys, i+1)) +" ["+ (string) llList2Integer(newkeys, i) + "m]"); } }}History
Section titled “History”- New function proposed by LL, reconciling the feature suggestions SVC-805, SVC-6427, MISC-243 and SVC-5488.
- Pre-Released Release_Notes/Second_Life_RC_Magnum/12 - Original JIRA requested
llGetRegionAgents(), the name changed since the released function does more. - Date of Release 30/04/2012
Known issues
Section titled “Known issues”From the issue templates included by the wiki article:
- SCR-311 (bug): llGetAgentList() with scope AGENT_LIST_PARCEL or AGENT_LIST_PARCEL_OWNER returns empty list when attached to avatar (fixed)
- BUG-40680 (nf): AGENT_LIST_LIMIT option for llGetAgentList()
- BUG-40681 (nf): llGetNumberOfAgents() - companion to llGetAgentList() for retrieving count only.
The wiki article also includes shared templates whose conditional content is not reproduced here: Template:Issues/SVC-5488, Template:Issues/MISC-243, Template:Issues/BUG-227045.
See also
Section titled “See also”Functions
Section titled “Functions”Original wiki source
Some wiki templates and tables need their original context. View this article on the Second Life Wiki. Technical wording and examples are retained from the source; historical guidance may differ from current behavior.