Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Online indicator indicates wrong.

Paul Wardark
Wait, what?
Join date: 10 Jan 2009
Posts: 383
10-12-2009 18:26
Somebody was helping me with this, then apparently gave up. Anyone know why the hovertext wouldn't change even thouh the primparams would?

CODE


string av_name;
key av_key;

integer i_am_online = FALSE;

key NameRequest;
key OnlineRequest;

default
{
state_entry()
{
llSetTimerEvent(5);
llSay(0, "To use me, simply put an avatar key in my description. " +
"If you don't know your key, simply click me and I'll tell you what it is.");
}

dataserver(key queryid, string data)
{
if(queryid == NameRequest)
{
av_name = data;
}
if(queryid == OnlineRequest)
{
if (data == "1")
{
if (!i_am_online)
{
llSetPrimitiveParams([
PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
PRIM_GLOW, ALL_SIDES, 0.25,
PRIM_COLOR, ALL_SIDES, <0.0,1.0,0.0>, 1
]);
llSetText( av_name + " is Online", <0.0,1.0,0.0>, 1);
llInstantMessage(llGetOwner(), av_name + " is Online");
i_am_online = TRUE;
}
}
else
{
if(i_am_online)
{
llSetPrimitiveParams([
PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
PRIM_GLOW, ALL_SIDES, 0.25,
PRIM_COLOR, ALL_SIDES, <1.0,0.0,0.0>, 1
]);
llSetText( av_name + " is Offline", <1.0,0.0,0.0>, 1);
llInstantMessage(llGetOwner(), av_name + " is Offline");
i_am_online = FALSE;
}
}
}
}

timer()
{
key new_av = (key)llGetObjectDesc();

if(new_av != av_key)
{
av_key = new_av;

NameRequest = llRequestAgentData(av_key, DATA_NAME);
}

if(av_key != "")
{
OnlineRequest =llRequestAgentData(av_key, DATA_ONLINE);
}
}

touch_start(integer num)
{
llSay(0, llDetectedName(0) + " has touched me and their key is " + (string) llDetectedKey(0));
}

on_rez (integer start_param)
{
llResetScript();
}
}

_____________________
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-12-2009 23:23
No idea... Any way, I re-wrote your dataserver event in a way that I know shouldn't fail.

First, change the following line in the global declarations:

integer i_am_online = -1; // Anything but 0/1 or TRUE/FALSE

Then, the new dataserver event:

dataserver(key queryid, string data)
{
if (queryid == NameRequest)
{
av_name = data;
}
else if (queryid == OnlineRequest)
{
integer status = (integer)data;
if (status != i_am_online) // If a change occured...
{
i_am_online = status;
vector color = <!i_am_online, i_am_online, 0.0>;
data = av_name + " is " + llList2String(["Offline", "Online"], i_am_online);
// I re-use 'data' which is a string.
llSetPrimitiveParams([
PRIM_FULLBRIGHT, ALL_SIDES, TRUE,
PRIM_GLOW, ALL_SIDES, 0.25,
PRIM_COLOR, ALL_SIDES, color, 1
]);
llSetText(data, color, 1);
llInstantMessage(llGetOwner(), data);
}
}
}

And in the timer, just after:

av_key = new_av;

And before the llAgentDataRequest(), add:

i_am_online = -1; // Anything but 0/1 or TRUE/FALSE

It will work. However you may still have some "false positive" status, both ways. Expect an AV to be reported offline only a few minutes after he/she logs off. I am sure of that... but I don't remember what's the delay to acknowledge that an AV is online.
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-13-2009 06:16
actually anything but 0 is true, negative or positive, or does that not matter when compared to the constant?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
10-14-2009 20:55
It matters here. The answer to llAgentDataRequest() in the dataserver() event is either 0 or 1. But the script doesn't care about the values, it just checks for a change.

I set the 'i_am_online' to anything but 0/FALSE or 1/TRUE in order to make it "believe" that a change of status occured when it runs for the first or when the avatar key has changed. So when the status actually becomes 0 or 1, it will reset the color and hovertext.

It's as simple as that...
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
10-14-2009 21:18
that's what i meant about it not mattering, i mean that it doesn't matter that anything other than zero is "true" because you're starting with -1 and comparing that to 0 and 1 which are the 2 values returned when checking online status.

if you start with false, and the user being checked is offline, no change will occur until they come online, which is what you fixed
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369