User:Fred Gandt/Scripts/Continued 2

From Second Life Wiki
< User:Fred Gandt‎ | Scripts
Revision as of 21:22, 13 February 2010 by Fred Gandt (talk | contribs) (→‎Free Scripts: Added online status script)
Jump to navigation Jump to search
FG jpg.jpg

My Contributions

Other Pages

Free Scripts

More Free Scripts

Legal Stuff

The legal stuff about contributing to this wiki (worth reading).

Tuition

Tuition scripts, notes, videos and screenshots etc. (hardly any content yet)

Free Scripts

Online Status Display & Pager

This will display the owners profile picture and a color coded and text texture sign that changes depending on the owners online status.

Just drop the script into a fresh prim.

<lsl>key owner_id;

string owner_name;

key ON_OFF_line = "124cfcec-6b8d-552c-42b8-6a1179884e74";

string profile_url = "http://world.secondlife.com/resident/";

key name_id;

key online_id;

key touch_request_id;

integer lis;

integer channel;

key requester;

OnlineStatus(integer ol, integer tr) {

   list ol_params = [];
   if(ol)
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD),
                18, 5, <0.0,1.0,0.0>, 1.0,
                18, 6, <1.0,1.0,1.0>, 1.0];
   else
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD),
                18, 5, <1.0,0.0,0.0>, 1.0,
                18, 6, <0.5,0.5,0.5>, 1.0];
   llSetPrimitiveParams(ol_params);
   if(tr)
   {
       llSetTimerEvent(30.0);
       if(ol)
       {
           lis = llListen(channel, "", requester, "");
           llDialog(requester, ("\nWould you like to page " + owner_name + "?"), ["YES", "NO"], channel);
       }
       else
       llInstantMessage(requester, (owner_name + " is currently offline."));
   }

}

default {

   state_entry()
   {
       owner_id = llGetOwner();
       name_id = llRequestAgentData(owner_id, DATA_NAME);
       channel = -5647;
   }
   dataserver(key q, string data)
   {
       if(q == name_id)
       {
           owner_name = data;
           llSetObjectName(owner_name + "'s Online Status");
           llHTTPRequest((profile_url + ((string)owner_id)), [], "");
       }
       else if(q == online_id)
       OnlineStatus(((integer)data), FALSE);
       else if(q == touch_request_id)
       OnlineStatus(((integer)data), TRUE);
   }
   http_response(key q, integer status, list metadata, string body)
   {
       integer tex_key_start = (llSubStringIndex(body, "imageid") + 18);
       integer tex_key_end = (tex_key_start + 35);
       key profile_image = ((key)llGetSubString(body, tex_key_start, tex_key_end));
       llSetPrimitiveParams([9, 0, 0, <0.6,0.875,0.0>, 0.02, ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR,
                             8, llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                             7, <0.85,0.01,0.6>,
                             17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                             18, -1, ZERO_VECTOR, 1.0]);
       llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD),
                             17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD),
                             19, 5, 0, 1,
                             18, 6, <1.0,1.0,1.0>, 1.0,
                             18, 5, <0.0,1.0,0.0>, 1.0,
                             20, 5, 1,
                             20, 6, 1]);
       llSetTimerEvent(0.1);
   }
   timer()
   {
       llListenRemove(lis);
       llSetTimerEvent(10.0);
       online_id = llRequestAgentData(owner_id, DATA_ONLINE);
   }
   touch_start(integer nd)
   {
       llSetTimerEvent(0.0);
       requester = llDetectedKey(0);
       touch_request_id = llRequestAgentData(owner_id, DATA_ONLINE);
   }
   listen(integer chan, string name, key id, string msg)
   {
       llListenRemove(lis);
       llSetTimerEvent(10.0);
       if(msg == "YES")
       {
           llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
           llInstantMessage(requester, owner_name + " has been paged.");
       }
   }

}</lsl>