Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help on Online Status script

Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
02-24-2009 11:36
Right I have been trying to alter a script I had a free one for online status, All I want is it to show on the text on or off line above an object, I dont want a message left or indeed for the prim to change colour, I think I'm nearly there but not quite.

As it not working exactly here it is

key user_key = "00000000-0000-0000-0000-000000000000"; // must be agent UUID whose status it will indicate
integer time = 30; // time within the message should be written.
string url = "http://world.secondlife.com/resident/";
key blank = "5748decc-f629-461c-9a36-a35a221fe21f";
string name;
key toucher;
string status;

default
{
state_entry()
{
llSetText("Nisa Maverick is Online", <1,0,0>, 1.0);

llRequestAgentData( user_key, DATA_NAME);
}
dataserver(key queryid, string data)
{
name = data;
llSetObjectName(name + "'s Online Detector";);
state show;
}
}
state show
{
state_entry()
{
llSetTimerEvent(10);
}
timer()
{



{

}
}
dataserver(key queryid, string data)
{
if ( data == "1" )
{
status = " is online";

llSetText(name + status, <0,1,0>, 1.0);
}
else if (data == "0";)
{
status = " is offline";

llSetText(name + status, <1,0,0>, 1.0);
}
}
}

Not sure what I have missed off as it still shows and states I'monline when I'm off.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-24-2009 11:59
Well, in your llRequestAgentData call, you really want to ask for DATA_ONLINE. Right now, you're asking for your own name, which you already know, so you can just type it in, instead of searching for it. You can squish your whole script into a single state, since you only need one dataserver event. For a minimal script, all you really need is .....

CODE

key reqID= NULL_KEY;
default
{
state_entry()
{
reqID = llRequestAgentData(llGetOwner(), DATA_ONLINE);
}
dataserver (key ID, string data)
{
(if ID == reqID)
{
if(data == TRUE)
{
llSetText("Nisa Maverick is online.", <0,1,0>, 1.0);
}
else
{
llSetText("Nisa Maverick is offline.", <1,0,0>,1.0);
}
}
}
}
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
02-24-2009 12:08
That script wouldn't refresh the status as it doesn't have a timer.

This is a simple one but should work, assuming you put the right key and name. If you wanted to be fancy you would have it get the name from the key, but I'm lazy :)

CODE


key user_key = "5748decc-f629-461c-9a36-a35a221fe21f";
string user_name = "Nisa Maverick";

default
{
state_entry()
{

llSetTimerEvent(15);

}

dataserver(key queryid, string data)
{

if (data == "1") llSetText(user_name+" is Online", <0,1,0>, 1.0);
else llSetText(user_name+" is Offline", <1,0,0>, 1.0);

}

timer()
{
llRequestAgentData( user_key, DATA_ONLINE);
}

}

_____________________
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
02-24-2009 12:17
Ooops! Right. I typed faster than my brain was working. Thanks, Darien. :o
Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
02-24-2009 12:28
From: Darien Caldwell
That script wouldn't refresh the status as it doesn't have a timer.

This is a simple one but should work, assuming you put the right key and name. If you wanted to be fancy you would have it get the name from the key, but I'm lazy :)

CODE


key user_key = "5748decc-f629-461c-9a36-a35a221fe21f";
string user_name = "Nisa Maverick";

default
{
state_entry()
{

llSetTimerEvent(15);

}



I just tried that script thanks, but it didnt work, it showed be online but I went offline and it stayed still showing me online?

dataserver(key queryid, string data)
{

if (data == "1") llSetText(user_name+" is Online", <0,1,0>, 1.0);
else llSetText(user_name+" is Offline", <1,0,0>, 1.0);

}

timer()
{
llRequestAgentData( user_key, DATA_ONLINE);
}

}



I tried that script thanks, but it doesnt seem to work it showed me online but I went offline and my partner says it still showed me online.
Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
02-24-2009 12:35
Sorry I take it all back I forgot to put my key in all is well thank you,
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
02-24-2009 12:35
Just one more in the spirit of your first post:
CODE

key user_key = "00000000-0000-0000-0000-000000000000";
float time = 30;
string name;
string status;

default {
state_entry() {
llSetText("", <0, 0, 0 >, 1.0);
llRequestAgentData(user_key, DATA_NAME);
}
timer() {
llRequestAgentData(user_key, DATA_ONLINE);
}
dataserver(key queryid, string data) {
if((integer)data == 1){
status = " is online";
}
else if(!(integer)data == 0){
status = " is offline";
}
else {
name = data;
llRequestAgentData(user_key, DATA_ONLINE);//So you don't have to wait the first time
llSetTimerEvent(time);
}
llSetText(name + status, <1, 0, 0 >, 1.0);
}
}


EDIT: Follow the bouncing ball.

1)It asks for the name that goes with the key
2)When it receives the name it asks for the online status and starts the timer
3)Timer asks for the online status
4)Whenever there is a data server event the set text is refreshed
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum