You are currently browsing the tag archive for the ‘on-line’ tag.

One common item which you will find around Second Life is the ‘owner on-line’ indicator. There are various different versions of these, but most of them change color and display some floating text to say whether the owner is on-line.

Here is a script which implements this. It uses the llRequestAgentData function to find out whether the owner is on-line. This reports the information back to the script via the dataserver event, which then changes the text message and the color of the prim appropriately.

string ownerName;
key onlineQry;
init()
{
 // Store the owner's name.
 ownerName = llKey2Name(llGetOwner());
 // Send a request for the information. This will
 // be sent back in the dataserver event.
 onlineQry = llRequestAgentData(llGetOwner(), DATA_ONLINE);
 // Start a timer to regularly check the on-line
 // status.    
 llSetTimerEvent(30.00);
}
default
{
 state_entry()
 {
  init();
 }
 on_rez(integer r)
 {
  init();
 }
 timer()
 {
  onlineQry = llRequestAgentData(llGetOwner(), DATA_ONLINE);    
 }
 dataserver(key query_id, string data) 
 {
  vector prim_color;
  if (query_id == onlineQry)
  {
   // The data parameter holds TRUE if the owner
   // is on-line.
   if ((integer)data == TRUE)
   {
    // Change the text.
    llSetText(ownerName + " is on-line", <0.0, 1.0, 0.0>, 0.5);
    // Set the object color to green.
    prim_color = <0.0, 1.0, 0.0>;
    llSetColor( prim_color, ALL_SIDES );
   }
   else
   {
    // Change the text.
    llSetText(ownerName + " is off-line", <1.0, 0.0, 0.0>, 0.5);
    // Set the object color to grey.
    prim_color = <0.5, 0.5, 0.5>;
    llSetColor( prim_color, ALL_SIDES );
    }
   }
 }
 changed(integer change)
 {
  if (change & CHANGED_OWNER) 
  {
   // We have changed owner. Reset the script to
   // make sure that we pick up the change
   // correctly.
   llResetScript();
  }
 }
}