llGetUsername
string llGetUsername(key AvatarID)Returns the username of an avatar, if the avatar is connected to the current region, or if the name has been cached. Otherwise, returns an empty string. Use llRequestUsername if the avatar may be absent from the region.
Parameters
-
AvatarID(key)
// Best viewed in Chat History (ctrl-h)default{ collision_start(integer a) // Announce who collided { llSay(0, "llGetDisplayName: " + llGetDisplayName(llDetectedKey(0)) + "\nllGetUsername: " + llGetUsername(llDetectedKey(0))); } touch_start(integer a) { llSay(0, "llGetDisplayName: " + llGetDisplayName(llDetectedKey(0)) + "\nllGetUsername: " + llGetUsername(llDetectedKey(0))); }}Caveats
Section titled “Caveats”- To get around the “avatar must be present” limitation, you can use the
llRequestUsernamefunction and thedataserverevent to obtain the avatar’s username from a key. - There is no opposite function (
llUsername2Key) available. For Name2Key services seellKey2Name. - An empty string can be returned if the region is unable to resolve the username. This can happen even if the avatar is present and display names are enabled on the region. Do not rely on this function to verify avatar presence.
- If you merely wish to show the agent username in the viewer window, it may be more straightforward to use Viewer URI Name Space, e.g.:
llSay(0, "secondlife:///app/agent/" + (string)id + "/username");