Triggered when task receives asynchronous data

Syntax

dataserver( key queryid, string data )

Event ID: 24.

Parameters

key queryid (handle)
matches the return of the requesting function
string data
the requested data (cast as a string as necessary).

Constants

FunctionInputDecodeDescription
llGetNotecardLinestringThe line in the requested notecard, limited to 255 bytes.
If EOF the line requested is past the end of the notecard.
llGetNumberOfNotecardLines(integer)The number of lines in the notecard requested.
llRequestAgentDataDATA_ONLINE1(integer) booleanIf the requested agent is online
DATA_NAME2stringThe requested agent's legacy name
DATA_BORN3stringThe account creation/"born on" date as a string in an ISO 8601 format of YYYY-MM-DD.
DATA_RATING4llCSV2List()Deprecated: Returns [0, 0, 0, 0, 0, 0]
Used to return: [pos_behavior, neg_behavior, pos_appearance, neg_appearance, pos_building, neg_building]
DATA_PAYINFO8(integer) maskFlagDescription
PAYMENT_INFO_ON_FILE0x1If payment info is on file.
PAYMENT_INFO_USED0x2If payment info has been used.
llRequestDisplayNamestringThe agent's display name
llRequestUsernamestringThe agent's username (legacy format: "first.last")
llRequestUserKeystring namekeyThe agent's unique ID.
llRequestInventoryDataLandmark(vector)The vector data received by dataserver is a global position as an offset from the current region's origin (<0,0,0>). To obtain the absolute global position of a landmark, add llGetRegionCorner() to the vector.
llRequestSimulatorDataDATA_SIM_POS5(vector)The regions global position.
DATA_SIM_STATUS6stringValueDescription
"up"region currently up and running
"down"region currently down
"starting"region currently starting
"stopping"region currently stopping
"crashed"region has crashed
"unknown"region status unknown or unknown region
DATA_SIM_RATING7stringValueMaturity rating
"PG"
"MATURE"
"ADULT"
"UNKNOWN"rating or region unknown
llCreateKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
stringvalueThe value for the key-value pair. Maximum 2047 characters, or 4095 if using Mono. Note! This value may contain commas.
llDataSizeKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
integerusedNumber of bytes used
integerquotaNumber of bytes the key-store can utilize
llDeleteKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
stringvalueThe value for the key-value pair. Maximum 2047 characters, or 4095 if using Mono. Note! This value may contain commas.
llKeyCountKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
integerpairsnumber of keys-value pairs in the key-value store
llKeysKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
listkeysA list of keys (strings) used in the key-value store
llReadKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
stringvalueThe value for the key-value pair. Maximum 2047 characters, or 4095 if using Mono. Note! This value may contain commas.
llUpdateKeyValuellCSV2List()The string containing a comma-delimited list (cdl). llDumpList2String([ integer success ] + components);

String Components

integersuccessA boolean specifying if the transaction succeeded (1) or not (0).
integererrorAn XP_ERROR_* flag that describes why the operation failed.
stringvalueThe value for the key-value pair. Maximum 2047 characters, or 4095 if using Mono. Note! This value may contain commas.

Caveats

Examples

// Example script handling sequential data server events (notecard reading)

string notecardNameOrKey = "name or key of the notecard goes here";
key notecardQueryId;
integer notecardLine;//  first notecard line is 0, so we don't have to set notecardLine = 1 here

default
{
    state_entry()
    {
        llSay(0, "Reading notecard...");
        notecardQueryId = llGetNotecardLine(notecardNameOrKey, notecardLine);
    }

    dataserver(key query_id, string data)
    {
        if (query_id == notecardQueryId)
        {
            if (data == EOF)//  we have reached the EOF (end of file)
            {
                llSay(0, "No more lines in notecard, read " + (string) notecardLine + " lines.");
            }
            else
            {
            //  increment line index first, both for line number reporting, and for reading the next line
                ++notecardLine;
                llSay(0, "Line " + (string) notecardLine + ": " + data);
                notecardQueryId = llGetNotecardLine(notecardNameOrKey, notecardLine);
            }
        }
    }
}
// Example script handling multiple data server events

list events;
integer stride = 3;

default
{
    touch_start(integer num_detected)
    {
        key id = llDetectedKey(0);
        events += [llRequestDisplayName(id), id, llGetUnixTime()];
        llSetTimerEvent(35.0);
    }

    dataserver(key request_id, string data)
    {
        integer index = llListFindList(events, [ request_id] );
        // The chance of getting a match on an avatar UUID instead of the dataserver event key, is less than 1 in 2^100

        if (~index )
        { 
            key id = llList2Key(events, index + 1);
            llRegionSayTo(id, 0, "Hello " + data + "!");

            events = llDeleteSubList(events, index, index + stride - 1);

            if (events == [])
                llSetTimerEvent(0);
        }
    }

    timer()
    {
        integer length = (events != []);

        // Loop until we find a valid entry (as all entries after will be valid too)
        while (length && llList2Integer(events, 2) < (llGetUnixTime() - 30))
        {
            events = llDeleteSubList(events, 0, stride - 1);
            length -= stride;
        }

        if (events == [])
            llSetTimerEvent(0);
    }
}

Notes

Deep notes

Issues