Islab Forums
Welcome to Islab Forums! Home World Current location Blog Current location Forum Directory Contact Sitemap Print this page Bookmark this page

Go Back   Islab Forums > Islab Forums > 居民帮助与交流
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply Bookmark this page at del.icio.us
 
Thread Tools Display Modes
  #1  
Old 01-15-2008, 08:41 PM
zhaoke's Avatar
zhaoke zhaoke is offline
Ken March in SL
 
Join Date: Dec 2006
Location: Islab.org
Posts: 348
Default Second Life用户标识符查询脚本

赵珂(islab.org/cn), 易思社区
http://islab.org/forum/showthread.php?t=134

Second Life中每一位用户都有唯一的全局统一标识(UUID, Globally unique identifier的缩写), 也叫做Key, 用户有key, 其它如基本物体(prim), 材质(texture)等等也有.

本文提供两种方法在Second Life中查询用户的标识符.

1. 查询任何用户的标识符
把下面脚本放到任何物体中, 然后在物体前面通过输入文字聊天消息来查询任何用户的标识符:
/100 suzy zhora

示图:
Name:  query_avuuid.gif
Views: 229
Size:  8.6 KB

Code:
 
//Used to store the ID of the request made with llHTTPRequest
key requestID;
//Used to store the listen ID
integer listenID;
default
{
    state_entry()
    {
        //Remove any old listen
        llListenRemove(listenID);
 
        //Setup a new listen on channel 100, just for the object owner
        listenID = llListen(100,"",llGetOwner(),"");
    }
 
    listen( integer chan, string name, key id, string msg )
    {
        //Get the avatar name from chat and replace spaces with + signs to conform to standards
        string avatarName = llDumpList2String(llParseString2List(msg,[" "],[]),"+");
 
        //Call the http name2key service with the avatar name
        requestID = llHTTPRequest("http://www.sldata.com/public/name2key/query.php?avname="+avatarName,[HTTP_METHOD,"GET"],"");
    }
 
    //http_response runs when the response to a llHTTPRequest arrives
    http_response(key request_id, integer status, list metadata, string body)
    {
        //Check for a success response
        if (status == 200 && request_id == requestID) {
 
            //Split the response up into its parts
            list bits = llParseString2List(body,[","],[]);
 
            //Extract the avatar name
            string avatarName = llList2String(bits,0);
 
            //Extract the avatar key
            string avatarKey = llList2String(bits,1);
 
            //If the avatar key == -1 then the service couldn't find the avatar
            if (avatarKey == "-1") {
                llOwnerSay("There is no avatar named "+avatarName);
            } else {
                //Otheriwse we found the avatar and we ouput the key
                llOwnerSay("Avatar "+avatarName+"'s key is: "+avatarKey);
            }
        } else {
            //If the system isn't available this code block will run
            llOwnerSay("Sorry, the service is not currently available");
        }
    }
}
2. 查询自己的标识符
把下面脚本放到任何物体中, 然后点击物体.

示图:
Name:  query_myuuid.gif
Views: 230
Size:  11.7 KB

Code:
 
string name;
string mkey;
default
{
    touch_start(integer total_number)
    {
 
        name = llDetectedName(0);
        mkey = llDetectedKey(0);
 
        //llSay(0, name + ", your UUID is: " + mkey );
        llSetText(name +", your UUID is:" + mkey, <0, 1, 0>, 1.0);
    }
}
相关资源:
1. Second Life用户标识符Web查询
2. Second Life术语词汇表
__________________
如果你有任何建议, 问题或想法, 欢迎发到论坛上.
If u have any comments, questions or ideas, please post here.
Reply With Quote
  #2  
Old 01-15-2008, 11:45 PM
reachcool reachcool is offline
Junior Member
 
Join Date: Nov 2007
Posts: 6
Default

我目前只会第二种,需要加紧学习啊
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT +8. The time now is 04:35 PM.   RSS Feed


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.