![]() |
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|
|
Thread Tools | Display Modes |
|
#1
|
||||
|
||||
|
赵珂(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 示图: 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");
}
}
}
把下面脚本放到任何物体中, 然后点击物体. 示图: 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. |
|
#2
|
|||
|
|||
|
我目前只会第二种,需要加紧学习啊
|