User:LindaB Helendale/Name2Key

From Second Life Wiki
Revision as of 03:52, 1 April 2013 by LindaB Helendale (talk | contribs) (Created page with "{{LSL Header}} Simple name2key script to find the key of an avatar. Usage: /1 firstname surname To use with the LindaBeamArray object scanner, get the key with this script and …")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Simple name2key script to find the key of an avatar.

Usage: /1 firstname surname

To use with the LindaBeamArray object scanner, get the key with this script and use search keyword /key <user key> instead of /owner <user name>


<lsl> // Name2key using w-hat service // Usage: /1 firstname surname integer CMDCHANNEL=1;

key reqid; string NAME;

default {

   state_entry()
   {
       llListen(CMDCHANNEL,"",llGetOwner(),"");
   }
   
   listen( integer channel, string name, key id, string message)
   {
       string URL   = "http://w-hat.com/name2key"; // name2key url
       NAME=message;
       reqid = llHTTPRequest( URL + "?terse=1&name=" +
                              llEscapeURL(NAME), [], "" );
   }
   http_response(key id, integer status, list meta, string body) {
       if ( id != reqid )
           return;
       if ( status == 499 )
           llOwnerSay("name2key request timed out");
       else if ( status != 200 )
           llOwnerSay("the internet exploded!!");
       else if ( (key)body == NULL_KEY )
           llOwnerSay("No key found for " + NAME);
       else
           llOwnerSay(NAME + "  Key: " + body );
   }

} </lsl>