ONLINE INDICATOR AND PAGER

Thread Started By steadymobbin

1709
0
  • 27 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rate Thread
#1
PHP Code:
key owner_id// Use to store the UUID of the owner to save having to keep asking.
 
string owner_name// Use to store the name of the owner to save having to keep asking.
 
// This a UUID of a texture I created to show either the word "ONLINE" or "OFFLINE".
key ON_OFF_line "124cfcec-6b8d-552c-42b8-6a1179884e74";
 
// This is added to the owner UUID to make an HTTP request for the owners profile image UUID.
string profile_url "http://world.secondlife.com/resident/";
 
key name_id// This key is used to recognize the dataserver request if it is for the name of the owner.
 
key online_id// This key is used to recognize the dataserver request if it is made automatically.
 
key touch_request_id// This key is used to recognize the dataserver request if it is made by a user.
 
key update_id// Used to verify that the HTTP request is for an update of the profile texture.
 
integer lis// This is used to store the value of a listen and to remove it when not needed.
 
integer channel// This is used to store the value of the listen channel.
 
key requester// This is used to store the name of a user who asks to page the owner.
 
string date// Used to store the date (just in case you couldn't guess).
 
OnlineStatus(integer olinteger tr// This function carries two integer type pieces of info.
// integer ol is the the boolean online data. 1 for online and zero for offline.
  // integer tr is also boolean. It carries whether the function is being called by a user or automatically.
    
list ol_params = []; // This is a local list creation.
    
if(ol// If the owner is online...
    
ol_params = [175ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying ONLINE.
                 
185, <0.0,1.0,0.0>, 1.0,
                 
186, <1.0,1.0,1.0>, 1.0];
    else 
// If not...
    
ol_params = [175ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying OFFLINE.
                 
185, <1.0,0.0,0.0>, 1.0,
                 
186, <0.5,0.5,0.5>, 1.0];
    
llSetPrimitiveParams(ol_params); // Set the object parameters to show whatever the list is.
    
if(tr// If this was a touch request...
    
{
        
llSetTimerEvent(30.0); // Prepare to be ignored (we need to switch the listen off if we are ignored).
        
if(ol// If the owner is online...
        
{
            
lis llListen(channel""requester""); // Open a listen for the user who made the request.
            
llDialog(requester, ("\nWould you like to page " owner_name "?"), ["YES""NO"], channel); // Send them a dialog.
        
}
        else 
// If not...
        
llInstantMessage(requester, (owner_name " is currently offline.")); // Send a message explaining that the owner is offline.
    
}
}
 
default 
// Create an area for the events to play in. This is called a "state".
{
    
state_entry() // On state entry...
    
{
        
owner_id llGetOwner(); // Get the owner UUID (key) and store it.
        
name_id llRequestAgentData(owner_idDATA_NAME); // Make a request for the owners name.
        
channel = -5647// Set a channel to use for the dialog.
    
}
    
dataserver(key qstring data// Triggered when a reply to a data request is recieved.
    
{
        if(
== name_id// Check the id of the request.
        
{
            
owner_name data// Store the result.
            
llSetObjectName(owner_name "'s Online Status"); // Set the name of the object to the owner name + "'s Online Status".
            
llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request the UUID of the owners profile.
        
}
        else if(
== online_id// Check the id of the request.
        
OnlineStatus(((integer)data), FALSE); // Call the OnlineStatus function for an automatic return.
        
else if(== touch_request_id// Check the id of the request.
        
OnlineStatus(((integer)data), TRUE); // Call the OnlineStatus function for a touch-by-user return.
    
}
    
http_response(key qinteger status, list metadatastring body// Triggered when a response for an HTTP request is recieved.
    
{
        
integer tex_key_start = (llSubStringIndex(body"imageid") + 18); // Establish the point where the image UUID is written in the page.
        
integer tex_key_end = (tex_key_start 35); // Establish the point where the image UUID ends.
        
key profile_image = ((key)llGetSubString(bodytex_key_starttex_key_end)); // Store the the profile image UUID found.
        
if(!= update_id// Check the source of the request.
        
{
            
llSetPrimitiveParams([900, <0.6,0.875,0.0>, 0.02ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR// Shape the object...
                                  
8llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                                  
7, <0.85,0.01,0.6>,
                                  
17, -1TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR0.0,
                                  
18, -1ZERO_VECTOR1.0]); // ...and texture it with the owners profile image and...
            
llSetPrimitiveParams([176profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD),
                                  
175ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // the ON/OFFline texture.
                                  
19501,
                                  
186, <1.0,1.0,1.0>, 1.0,
                                  
185, <0.0,1.0,0.0>, 1.0,
                                  
2051,
                                  
2061]);
            
llSetTimerEvent(0.1); // Move to the timer quickly to run the first OnlineStatus check.
        
}
        else
        
llSetPrimitiveParams([176profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD)]); // Apply the updated profile texture.
    
}
    
timer() // Triggered if a timer event is set to a non zero amount.
    
{
        
llSetTimerEvent(10.0); // Reset the timer event to trigger every 10 seconds.
        
llListenRemove(lis); // Always remove any listen we have open.
        
online_id llRequestAgentData(owner_idDATA_ONLINE); // So every 10 seconds we check if the owner is online.
        
string t_date llGetDate(); // Find out what the date is.
        
if(t_date != date// Check if the date has changed. If it has...
        
{
            
date t_date// ...store the date so the next check to return true will be roughly 24 hours later.
            
update_id llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request an update of the UUID of the owners profile.
        
}
    }
    
touch_start(integer nd// Triggered on clicking the object that contains the script.
    
{
        
llSetTimerEvent(0.0); // Stop the timer.
        
requester llDetectedKey(0); // Store the UUID of the person who touched us.
        
touch_request_id llRequestAgentData(owner_idDATA_ONLINE); // Request the online status of the owner before issuing any dialogs.
    
// We do this becuse if the owner went offline 9 seconds ago we wouldn't know.
    
listen(integer chanstring namekey idstring msg// Triggered when all the specified info is recieved by the script if it has a listen open.
    
{
        
llListenRemove(lis); // Remove the listen.
        
llSetTimerEvent(10.0); // Set the timer to run automatically.
        
if(msg == "YES"// If the toucher wants to page the owner (the owner must be online)...
        
// Instant message the owner with a link that when clicked will bring up the touchers profile. This saves searching for the touchers profile.
            
llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
            
llInstantMessage(requesterowner_name " has been paged."); // Inform the toucher that the owner has been paged.
        
}
    }

[Image: guns-bullet-shirt_recreated.jpg]
Reply




Possibly Related Threads…
Thread Author Replies Views Last Post
  Online Indicator with Email and IM steadymobbin 0 1,737 02-18-2013, 02:24 AM
Last Post: steadymobbin

Forum Jump:

1 Guest(s)
Share this:

About Second Life Copybot

Second Life CopyBot Forum is a place where you can get items for Second Life and other vitual worlds for free. With our CopyBot viewers you can export and import any content from these virtual worlds and modify them in 3D software such as Blender, 3D studio Macx etc...