# llRequestAgentData

*LSL function*

```lsl
key key llRequestAgentData(key id, integer data);
```

- `key id`: UUID of the agent.
- `integer data`: DATA_* category flag of the requested information.

- Returns: `key`
- Delay: 0.1 s
- Energy: 10

Asynchronously requests the specified data category (DATA_*) about the agent id. Triggers a dataserver event with the results and returns a key query handle.

Requests **data** about agent **id**. When **data** is available the [dataserver](/events/dataserver/) event will be raised

```lsl title="How to use" frame="terminal"
key result = llRequestAgentData(NULL_KEY, 0);
```

## Specification

<table>
	<tr>
		<th colspan="2">**data** Constant</th>
		<th>Type</th>
		<th colspan="4">Description</th>
	</tr>
</table>

## Caveats

- [DATA_BORN](/constants/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](/events/dataserver/) will **not** be raised.

## Examples

**[DATA_NAME](/constants/DATA_NAME/)**

```lsl collapse={1-7, 13-20}
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](/constants/DATA_ONLINE/)**

```lsl collapse={1-16, 22-58}
/*
    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();
    }
}
```

## Known issues

From the issue templates included by the wiki article:

- SVC-215 (nf): **llRequestAgentKey**() (**llName2Key**())
- SVC-6831 (bug): llRequestAgentData with DATA_ONLINE parameter has a delay of up to 10 minutes in reporting offline status

## See also

### Functions

- [llGetAgentInfo](/functions/llGetAgentInfo/)

### Events

- [dataserver](/events/dataserver/)

---

*Source: [LlRequestAgentData](https://wiki.secondlife.com/wiki/LlRequestAgentData) on the Second Life Wiki. Content from the Second Life Wiki articles LlRequestAgentData (revision 1215048, 2023-10-14), Template:LSL Function/avatar (revision 1179236, 2013-06-15), Template:Issues/SVC-215 (revision 1050542, 2010-10-02) and Template:Issues/SVC-6831 (revision 1157344, 2011-11-06), CC BY-SA 3.0.*

---

From lsl.dev: https://lsl.dev/functions/llRequestAgentData/
