LlRequestAgentData
| 首页 | 函数 | 事件 | 类型 | 操作符 | 常数 | Flow Control | Script Library | Categorized Library | Tutorials |
| 函数名 |
|---|
| Function: key llRequestAgentData( key id, integer data ); |
| 参数:• key id – avatar UUID
• integer data – DATA_* flag |
| 返回值:请求有关代理id的数据。当数据可用时,将引发dataserver事件
返回dataserver事件引发时的句柄(键)。 |
| 注意事项 |
|---|
| 这个函数使脚本休眠0.1秒。
DATA_BORN不是UTC。它以太平洋时间为基础。 值得重申的是:如果请求的数据不存在——或者如果给定的键不是针对代理的——那么将不会引发dataserver。 |
| 示例 |
|---|
DATA_NAME
key owner_key;
key owner_name_query;
string owner_name;
default
{
state_entry()
{
owner_key = llGetOwner();
owner_name_query = llRequestAgentData(owner_key, DATA_NAME);
}
dataserver(key queryid, string data)
{
if ( owner_name_query == queryid )
{
owner_name = data;
llSay(0, "The owner of this script is called : " + owner_name );
}
}
}//Anylyn Hax 06:19, 23 July 2007 (PDT)
DATA_ONLINE /*
服务器友好的在线状态示例由Daemonika Nightfire。
对于服务器来说,每2分钟检查一下该区域是否有一个角色并不会带来很大的负载。
但是,在该地区没有人的情况下触发dataserver事件来获取在线状态是毫无意义的。
为此,脚本每次检查该区域的化身数量。
*/
key owner;
float repeat = 120.0; // 60 - 120 sec. Recommended, faster than 60 seconds and LL will kick your XXX.
key status_request;
Status()
{
integer agent_count = llGetRegionAgentCount();
if(agent_count > 0) // 如果该区域内没有人,则跳过该请求
{
status_request = llRequestAgentData(owner, DATA_ONLINE);
}
}
default
{
state_entry()
{
owner = llGetOwner();
llSetTimerEvent(repeat);
Status();
}
timer()
{
Status();
}
dataserver(key queryid, string data)
{
if(queryid == status_request)
{
// requested data contains the string "0" or "1" for DATA_ONLINE
// i convert it to an integer and use the boolean as index
//list index = [ 0, 1, 2(0+2), 3(1+2) ]
list status = ["OFFLINE","ONLINE",<1,0,0>,<0,1,0>];
string text = llList2String(status,(integer)data); // boolean/index = 0 or 1
vector color = llList2Vector(status,(integer)data+2); // boolean/index = 0+2 or 1+2
llSetText(text, color, 1.0);
}
}
on_rez(integer Dae)
{
llResetScript();
}
}
|
| 相关函数 |
|---|
| llGetAgentInfo |
| 相关事件 |
|---|
| dataserver |
附录:(表格)
| data Constant | Type | Description | ||
|---|---|---|---|---|
| DATA_ONLINE | 1 | (integer) boolean | 如果被请求的代理处于在线状态 | |
| DATA_NAME | 2 | string | 被请求代理的legacy name | |
| DATA_BORN | 3 | string | 账户创建/“born on”日期为一个字符串,格式为ISO 8601 YYYY-MM-DD。 | |
| DATA_RATING | 4 | llCSV2List() | Deprecated: Returns [0, 0, 0, 0, 0, 0]
Used to return: [pos_behavior, neg_behavior, pos_appearance, neg_appearance, pos_building, neg_building] | |
| DATA_PAYINFO | 8 | (integer) mask | Flag | Description |
| PAYMENT_INFO_ON_FILE 0x1 | 如果付款信息在档案中。 | |||
| PAYMENT_INFO_USED 0x2 | 如果付款信息已经被使用。 | |||