Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Limitation of llRequestAgentData?

Feline Slade
Hatstand 2.0™
Join date: 19 May 2007
Posts: 201
09-26-2007 04:25
I'm trying to make a single object that serves as an online indicator for more than one avatar. The final result will hopefully be a prim that has hovertext that says something like: "Mork is Offline, Mindy is Online"

The problem I am running into is that the script only seems to report the status of the last avatar queried in the script. Is there a limitation to llRequestAgentData that prevents it being able to return two different avatars' online status in a single script?
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
09-26-2007 05:53
I've done it for several agents in one script. You need to save the query ID key from each query separately, then test them one by one in the dataserver event.

I'm guessing that you're storing the return value from the request into the same integer each time, this would cause you to only retain the last query.
Feline Slade
Hatstand 2.0™
Join date: 19 May 2007
Posts: 201
09-28-2007 04:31
I don't think I'm doing that... I was careful not to trample the results of the call (I thought!). A a cleaned up version of the script is below. I removed the specific avatar keys from this example. Can you tell me if I'm not storing the integer properly?

key avatar;
key avatar2;
string mork_status;
string mindy_status;

default
{
state_entry()
{
llSetTimerEvent(10.0);
}

timer()
{

avatar = (key)"InsertKeyHere";
llRequestAgentData(avatar, DATA_ONLINE);
}

dataserver(key queryid4, string data4)
{

if (data4 == "1";)
mindy_status = "online";
else
mindy_status = "offline";
{

avatar2 = (key)"InsertKeyHere";
llRequestAgentData(avatar2, DATA_ONLINE);
}

dataserver(key queryid2, string data2)
{
if (data2 == "1";)
mork_status = "online";
else
mork_status = "offline";



llSay(0, "Mindy is " + mindy_status);
llSay(0, "Mork is " + mork_status);
}
}
Masakazu Kojima
ケロ
Join date: 23 Apr 2004
Posts: 232
09-28-2007 05:04
If you have multiple handlers for the same event, only the last is executed. Both llRequestAgentData calls will trigger the same event handler, but each call returns a different key, which will be passed as the first parameter of the dataserver() event.

Ex:

key mork_uuid = "12341234-1234-1234-1234-123412341234";
key mindy_uuid = "43214321-4321-4321-4321-432143214321";
key mork_qid;
key mindy_qid;
string mork_status = "offline";
string mindy_status = "offline";

default {

state_entry() {
llSetTimerEvent(10.0);
}

timer() {
mork_qid = llRequestAgentData( mork_uuid, DATA_ONLINE );
mindy_qid = llRequestAgentData( mindy_uuid, DATA_ONLINE );
}

dataserver( key qid, string data ) {

if ( qid == mork_qid ) {

if ( data == "1" ) mork_status = "online";
else mork_status = "offline";

} else if ( qid == mindy_qid ) {

if ( data == "1" ) mindy_status = "online";
else mindy_status = "offline";

} // if

llSetText( "Mindy is " + mindy_status + "\n" + "Mork is " + mork_status, <1,1,1>, 1.0);

} // dataserver

} // default