dataserver(key queryid, string data)
This
event handler is triggered when the requested data is
returned to the
script. Data may be requested using the
llGetNotecardLine,
llGetNumberOfNotecardLines,
llRequestAgentData,
llRequestInventoryData, and
llRequestSimulatorData functions.
The
queryid parameter is the key returned by any of these functions. The
data parameter is the requested information (see the descriptions of the function calls for information on how to interpret it). The dataserver event is raised for
all scripts in the prim. This is why it is necessary to check the
query id.
Dataserver answers aren't necessarily coming in the order they were requested in. So, if there are multiple pending requests, always use the
queryid key to determine which answer is being received. If only one request is processed at a time, and only one script is in the
prim that uses the dataserver event, this problem doesn't arise.
Note: Dataserver requests will trigger all
dataserver() events in all scripts within the same prim where the request was made.
dataserver() events will
not be triggered in scripts contained in other prims in the same
linked object. This is the same regardless of whether the prim in question is the
parent/
root prim, or a
child.
Remember: Erroneous requests silently fail and never cause a
dataserver() event to occur (e.g. if a
notecard line is requested, but a key is supplied that isn't pointing to a notecard). A
timer could catch these silent failures by checking to see if no
dataserver() event has occured after a defined time.
The dataserver is rather slow, so keep this in mind when using the aforementioned functions.
Functions:
Example:
Example of working with multiple requests: KriAyakashi
list avatars;
list requests;
key avatar;
default
{
state_entry()
{
llSensor("", NULL_KEY, AGENT, 96.0, PI);
}
sensor(integer num_detected)
{
integer i;
avatars = [];
requests = [];
for(i=0; i<num_detected; ++i)
{
avatar = llDetectedKey( i );
avatars += [avatar]; // to use less memory use this hack: avatars = (avatars=[]) + avatars + [avatar];
requests += [llRequestAgentData(avatar, DATA_BORN)]; // to use less memory use this hack: requests = (requests=[]) + requests + [llRequestAgentData(llDetectedKey(i), DATA_BORN)];
}
}
dataserver(key queryid, string data)
{
integer idx = llListFindList(requests, [queryid]);
avatar = llList2Key(avatars, idx); // as we added the requests in the same order as avatars
llOwnerSay(llKey2Name(avatar)+" was born "+data);
}
}
Functions |
Events