string llKey2Name(key id) 

If the object or agent identified by the key id is in the same simulator as the object containing the script, this function returns their name. Otherwise, an empty string ("") is returned. This can be misleading, because it cannot be distinguished from an object with an empty name (""). See llGetObjectDetails for a better function.

Only works on rezzed objects and avatars. Scripts, animations, and textures will return an empty string ("").

See llRequestAgentData for a (much slower) way to use the dataserver to get the name of an agent even outside the sim or offline.

Note: there is no llName2Key function. To get a key from a name, use sensors or touch events and the llDetected* functions.

Note: This function works if someone can see the sim from an adjacent sim. V1.9