Difference between revisions of "LlGetDisplayName"

From Second Life Wiki
Jump to: navigation, search
m (warnings & mode modifiers go in inject-1 & 2, content belongs in inject-2 & inject-3)
(saw some advice in a group chat to try and try until it works, eek!)
Line 15: Line 15:
 
* There is no opposite function ([[llDisplayName2Key]]) available since display names are non-unique
 
* There is no opposite function ([[llDisplayName2Key]]) available since display names are non-unique
 
* Either of "???" or "" is returned if the region is unable to return display names. This can happen even if display names are enabled on the region, especially the first time a given key is checked. At least one retry may be advisable. Do not rely on this function to verify avatar presence.
 
* Either of "???" or "" is returned if the region is unable to return display names. This can happen even if display names are enabled on the region, especially the first time a given key is checked. At least one retry may be advisable. Do not rely on this function to verify avatar presence.
 +
** Do ''not'' retry failed attempts indefinitely in a loop. In a few cases, a display name or username will not be returned for as long as the avatar is in the region.
 
|constants
 
|constants
 
|examples=<lsl>// Best viewed in Chat History (ctrl-h)
 
|examples=<lsl>// Best viewed in Chat History (ctrl-h)

Revision as of 15:02, 4 December 2010

Emblem-important-red.png Security Warning!

It is a terrible idea to tie any security measures to display names; they are not unique and can easily be changed.

Emblem-important-red.png Data Execution Warning!

Display names can contain quotes and some punctuation. While this is not a problem for LSL, remember to escape strings being passed to command line scripts, sql queries, etc.
See: XKCD: Exploits of a Mom

Summary

Function: string llGetDisplayName( key id );

Returns a string that is the non-unique display name of the avatar specified by id.

• key id avatar UUID that is in the same region or is otherwise known to the region

id must specify a valid avatar key, present in or otherwise known to the sim in which the script is running, otherwise an empty string is returned. This function will still return a valid display name if the avatar is a child agent of the sim (i.e., in an adjacent sim, but presently able to see into the one the script is in), or for a short period after the avatar leaves the sim (specifically, when the client completely disconnects from the sim, either as a main or child agent).

Caveats

  • To get around the "avatar must be present" limitation, you can use the llRequestDisplayName function and the dataserver event to obtain the avatar's display name from a key.
  • There is no opposite function (llDisplayName2Key) available since display names are non-unique
  • Either of "???" or "" is returned if the region is unable to return display names. This can happen even if display names are enabled on the region, especially the first time a given key is checked. At least one retry may be advisable. Do not rely on this function to verify avatar presence.
    • Do not retry failed attempts indefinitely in a loop. In a few cases, a display name or username will not be returned for as long as the avatar is in the region.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   Display Name and Username showing as ???

Examples

<lsl>// Best viewed in Chat History (ctrl-h) default {

   collision_start(integer a)//Announce who collided
   {
       llSay(0, "llGetDisplayName: " + llGetDisplayName(llDetectedKey(0)) +
              "\nllDetectedName: " + llDetectedName(0));
   }
   touch_start(integer a)
   {
       llSay(0,"llGetDisplayName: " + llGetDisplayName(llDetectedKey(0)) +
              "\nllDetectedName: " + llDetectedName(0));
   }
}</lsl>

See Also

Functions

•  llGetUsername
•  llRequestDisplayName Uses the dataserver to request avatar information

Deep Notes

All Issues

~ Search JIRA for related Issues
   Display Name and Username showing as ???

Signature

function string llGetDisplayName( key id );