Difference between revisions of "LlRequestAgentData"

From Second Life Wiki
Jump to navigation Jump to search
m (spacing)
m
(23 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{#vardefine:p_data_desc|DATA_* flag}}{{LSL_Function
{{LSL_Function
|inject-2={{LSL Function/avatar|id}}{{Issues/SVC-215}}{{Issues/SVC-6831}}
|func_id=155|func_sleep=0.1|func_energy=10.0
|func_id=155|func_sleep=0.1|func_energy=10.0
|func=llRequestAgentData
|func=llRequestAgentData
|return_type=key|p1_type=key|p1_name=id|p2_type=integer|p2_name=data
|return_type=key
|return_subtype=handle
|p1_type=key|p1_name=id
|p2_type=integer|p2_name=data|p2_desc=DATA_* flag
|func_footnote
|func_footnote
|func_desc=Requests '''{{LSL Param|data}}''' about agent '''id'''. When '''{{LSL Param|data}}''' is available the {{LSLG|dataserver}} event will be raised
|func_desc=Requests {{LSLP|data}} about agent {{LSLP|id}}. When {{LSLP|data}} is available the [[dataserver]] event will be raised
|return_text=that is used to identify the {{LSLG|dataserver}} event when it is raise.
|Return_text=for the [[dataserver]] event when it is raised.
|spec
|spec
|caveats
|caveats=*[[DATA_BORN]] is not UTC. It is Pacific Time based.
|constants={{{!}} {{Prettytable}}
* It's worth restating: if the requested data does not exist - or if the key given is not for an agent - then [[dataserver]] will '''not''' be raised.
|constants={{{!}} {{Prettytable|style=margin-top:0;margin-right:0;}}
{{!}}- {{Hl2}}
{{!}}- {{Hl2}}
! colspan="2" {{!}} {{LSL Param|data}} Constant
! colspan="2" {{!}} {{LSL Param|data}} Constant
Line 16: Line 21:
{{Template:LSL_Constants/llRequestAgentData}}
{{Template:LSL_Constants/llRequestAgentData}}
{{!}}}
{{!}}}
|examples=<pre>
|examples='''DATA_NAME'''<source lang="lsl2">key owner_key;
key owner_key;
key owner_name_query;
key owner_name_query;
string owner_name;
string owner_name;
Line 25: Line 29:
     state_entry()
     state_entry()
     {
     {
         owner_key = llGetOwner ();
         owner_key = llGetOwner();
         owner_name_query = llGetAgentInfo( owner_key, DATA_NAME);
         owner_name_query = llRequestAgentData(owner_key, DATA_NAME);
     }
     }
     dataserver(key queryid, string data)
     dataserver(key queryid, string data)
     {
     {
         if ( owner_name_query == queryid ) {
         if ( owner_name_query == queryid )
             owner_name = data ;
        {
             llSay(0, " The Owner of this script is called : "+ owner_name );
             owner_name = data;
             llSay(0, "The owner of this script is called : " + owner_name );
         }
         }
    }
}//Anylyn Hax 06:19, 23 July 2007 (PDT)</source>
'''DATA_ONLINE'''<source lang="lsl2">/*
    Server friendly online status example by Daemonika Nightfire.
   
    It is not a big load for the server to check every 2 minutes if there is an avatar in the region.
    But it is nonsense to trigger a dataserver event for online status when nobody is in the region.
    For this purpose, the script checks the number of avatars in the region on each pass.
*/
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) // skip the request if nobody is in the region
    {
        status_request = llRequestAgentData(owner, DATA_ONLINE);
     }
     }
}
}


</pre>Anylyn Hax 06:19, 23 July 2007 (PDT)
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();
    }
}</source>
|helpers
|helpers
|also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}}
|also_functions={{LSL DefineRow||[[llGetAgentInfo]]|}}
Line 44: Line 106:
|also_articles
|also_articles
|notes
|notes
|deepnotes=
If you merely wish to show avatar name information in the viewer window, it may be more straightforward to avoid a DATA_NAME dataserver event and simply output: <source lang="lsl2">llSay(0, "secondlife:///app/agent/" + (string)id + "/about");</source>
|deprecated
|deprecated
|cat1=Dataserver
|cat1=Dataserver
|cat2
|cat2=Avatar
|cat3
|cat3=Avatar/Name
|cat4
|cat4
}}
}}

Revision as of 14:48, 30 December 2019

Summary

Function: key llRequestAgentData( key id, integer data );

Requests data about agent id. When data is available the dataserver event will be raised
Returns the handle (a key) for the dataserver event when it is raised.

• key id avatar UUID
• integer data DATA_* flag

data Constant Type Description
DATA_ONLINE 1 (integerboolean If the requested agent is online
DATA_NAME 2 string The requested agent's legacy name
DATA_BORN 3 string The account creation/"born on" date as a string in an ISO 8601 format of 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 (integermask Flag Description
PAYMENT_INFO_ON_FILE 0x1 If payment info is on file.
PAYMENT_INFO_USED 0x2 If payment info has been used.

Caveats

  • This function causes the script to sleep for 0.1 seconds.
  • DATA_BORN is not UTC. It is Pacific Time based.
  • It's worth restating: if the requested data does not exist - or if the key given is not for an agent - then dataserver will not be raised.

Important Issues

~ All Issues ~ Search JIRA for related Bugs
   llRequestAgentData with DATA_ONLINE parameter has a delay of up to 10 minutes in reporting offline status

Examples

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
/*
    Server friendly online status example by Daemonika Nightfire.
    
    It is not a big load for the server to check every 2 minutes if there is an avatar in the region.
    But it is nonsense to trigger a dataserver event for online status when nobody is in the region.
    For this purpose, the script checks the number of avatars in the region on each pass.
*/


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) // skip the request if nobody is in the region
    {
        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();
    }
}

See Also

Events

•  dataserver

Functions

•  llGetAgentInfo

Deep Notes

If you merely wish to show avatar name information in the viewer window, it may be more straightforward to avoid a DATA_NAME dataserver event and simply output:
llSay(0, "secondlife:///app/agent/" + (string)id + "/about");

All Issues

~ Search JIRA for related Issues
   llRequestAgentKey() (llName2Key())
   llRequestAgentData with DATA_ONLINE parameter has a delay of up to 10 minutes in reporting offline status

Signature

function key llRequestAgentData( key id, integer data );