User:Cow Taurog/Name to key

From Second Life Wiki
Jump to navigation Jump to search

This script will listen on any number/channel for a link message with "resolvename" as the string, and "User Name" (a real name of course, not User Name) as the id. It will then resolve the UUID of that person using the alpha fox name to key service, and send a link message back on the same number/channel with "resolvedkey" as the string, and the user's UUID as the id. This service may not be around forever, and the script is subject to breakage should it no longer exist (donations are good). Place the first script, and then one of the example scripts below in the same prim, then touch to use it.

<lsl> string gsURL="http://name2key.alpha-fox.com/?name="; key httpRequestId; integer giComm;

default{

   link_message(integer sender,integer num,string mess,key id){if(mess=="resolvename"){
       giComm=num;
       httpRequestId=llHTTPRequest(gsURL+llEscapeURL(id),[],"");
   }}
   http_response(key request_id,integer status,list metadata,string body){if(request_id==httpRequestId){
       llMessageLinked(LINK_SET,giComm,"resolvedkey",llUnescapeURL(body));
       llResetScript();
   }}

} </lsl>
<lsl> // get key by touch default{

   touch_start(integer num){llMessageLinked(LINK_SET,1,"resolvename",llDetectedName(num-1));
   link_message(integer sender,integer num,string mess,key id){if(mess=="resolvedkey"){llOwnerSay(id);}}

} </lsl>
<lsl> // get key by chat default{

   touch_start(integer num){if(llDetectedKey(num-1)==llGetOwner()){llOwnerSay("Say the full name of the avatar you would like to find the UUID for over public chat, or /20.");llListen(0,"",llGetOwner(),"");llListen(20,"",llGetOwner(),"");}}
   listen(integer chan,string name,key id,string mess){llMessageLinked(LINK_SET,1,"resolvename",mess);}
   link_message(integer sender,integer num,string mess,key id){if(mess=="resolvedkey"){llOwnerSay(id);llResetScript();}}

} </lsl>