Dataserver
From Second Life Wiki
| LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Tutorials |
Description
! Event: dataserver( key queryid, string data ){ ; }| 24 | Event ID |
Triggered when task receives asynchronous data
| • key | queryid | – | matches the return of the requesting function | |
| • string | data | – | the requested data (cast as a string as necessary). |
| Function | Input | Decode | Description | ||||
|---|---|---|---|---|---|---|---|
| llGetNotecardLine | string | The 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. | |||||
| llRequestAgentData | DATA_ONLINE | 1 | (integer) boolean | If the requested agent is online | |||
| DATA_NAME | 2 | string | The requested agents 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] Use 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 | If payment info is on file. | |||||
| PAYMENT_INFO_USED | 0x2 | If payment info has been used. | |||||
| llRequestInventoryData | Landmark | (vector) | The vector data received by dataserver is an offset from <0,0,0> of the current region. To obtain the global position of a landmark add llGetRegionCorner(). | ||||
| llRequestSimulatorData | DATA_SIM_POS | 5 | (vector) | The regions global position. | |||
| DATA_SIM_STATUS | 6 | string | Value | Description | |||
| "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 simulator | ||||||
| DATA_SIM_RATING | 7 | string | region rating "PG", "MATURE", "ADULT" or "UNKNOWN" | ||||
Caveats
- Dataserver answers do not necessarily come in the order they were requested.
- If there are multiple pending requests, always use the queryid key to determine which answer is being received.
- Dataserver requests will trigger dataserver events in all scripts within the same prim where the request was made.
- If there are multiple scripts with dataserver events in the same prim, always use the queryid key to determine which answer is being received.
- dataserver events will not be triggered in scripts contained in other prims in the same linked object.
- If more data is requested using the same query_id before the dataserver event dealing with that query_id has resolved the data will be trashed. To avoid the trashing do not ask if(query_key == query_id). Though (see above caveats) this has its own drawbacks.
Examples
key kQuery; integer iLine = 0; default { state_entry() { llSay(0, "Reading notecard..."); kQuery = llGetNotecardLine("My Notecard", iLine); } dataserver(key query_id, string data) { if (query_id == kQuery) { // this is a line of our notecard if (data == EOF) { llSay(0, "No more lines in notecard, read " + (string)iLine + " lines."); } else { // increment line count llSay(0, "Line " + (string)iLine + ": " + data); //request next line ++iLine; kQuery = llGetNotecardLine("My Notecard", iLine); } } } }
Notes
- Requesting data from within the dataserver event is quite valid. However, be aware not to make your own loop inside the event. It will lock the event open until the loop is finished then send all the requests made from within, with the data from the first retrieval.
This article wasn't helpful for you? Maybe the related article at the LSL Wiki is able to bring enlightenment.

