LlGetAgentList
Looking for the current API? Open the llGetAgentList reference →
Wiki description
Return value notes
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_KEY returned instead of their real key with llGetAgentList(). There is also an issue with a certain type of ghosted agent still returning a key too. Perhaps check each key against llGetAgentSize() to verify if they're really in the sim or not; none of the above anomalies affect llGetAgentSize().
Examples
//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);
// 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;
}
}
}// 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);
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]");
}
}
}See also: functions
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
Shared wiki helpers
The original page also injects shared parameter notes, caveats or issue information through these helpers. Their conditional MediaWiki logic is not reproduced here; inspect the preserved helper source for additional material.
Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|SCR-311|type=bug|[[llGetAgentList]]() with scope [[AGENT_LIST_PARCEL]] or [[AGENT_LIST_PARCEL_OWNER]] returns {{HoverText|empty list|[]}} when [[attach]]ed to avatar|status=vfix|resolution=fixed}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|BUG-40680|'''AGENT_LIST_LIMIT''' option for [[llGetAgentList]]()|type=nf}}Original shared helper source (conditional wiki logic is not evaluated)
{{Issues|BUG-40681|'''llGetNumberOfAgents'''() - companion to [[llGetAgentList]]() for retrieving count only.|type=nf}}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.