Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- key owner_key;
- key owner_name_query;
- string owner_display_name;
- string username;
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // Copyright (c) 2008 by Kristy Fanshaw //
- ////////////////////////////////////////////////////////////////////////////////////////////////
- // This program is free software: you can redistribute it and/or modify //
- // it under the terms of the GNU General Public License as published by //
- // the Free Software Foundation, either version 3 of the License, or //
- // (at your option) any later version. //
- // //
- // Online Indicator is distributed in the hope that it will be useful, //
- // but WITHOUT ANY WARRANTY; without even the implied warranty of //
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
- // GNU General Public License for more details. //
- // //
- // To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. //
- ////////////////////////////////////////////////////////////////////////////////////////////////
- key user_key; // 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 = TEXTURE_BLANK;
- string name;
- key toucher;
- string status;
- // VD 2009-11-24 workaround for WEB-1383, use <meta> instead of <img>
- // VD 2009-11-25 try <img> if meta tag gets removed in the future
- string profile_key_prefix = "<meta name=\"imageid\" content=\"";
- string profile_img_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/";
- integer profile_key_prefix_length; // calculated from profile_key_prefix in state_entry()
- integer profile_img_prefix_length; // calculated from profile_img_prefix in state_entry()
- //string profile_key_prefix = "<meta name=\"imageid\" content=\"";
- //integer s1l;
- default
- {
- state_entry()
- {
- user_key = llGetOwner();
- profile_key_prefix_length = llStringLength(profile_key_prefix);
- profile_img_prefix_length = llStringLength(profile_img_prefix);
- llSetText("", <1,0,0>, 1.0);
- llSetTexture(blank, ALL_SIDES);
- //llRequestAgentData( user_key, DATA_NAME);
- owner_key = llGetOwner();
- owner_name_query = llRequestDisplayName(owner_key);
- }
- dataserver(key queryid, string data)
- {
- //name = data;
- owner_display_name = data;
- llSetObjectName(owner_display_name + "'s Online Detector");
- state show;
- }
- }
- state show
- {
- state_entry()
- {
- owner_key = llGetOwner();
- owner_name_query = llRequestDisplayName(owner_key);
- llSetTimerEvent(10);
- }
- timer()
- {
- llHTTPRequest( url + (string)user_key,[HTTP_METHOD,"GET"],"");
- llRequestAgentData( user_key, DATA_ONLINE);
- }
- on_rez(integer start_param)
- {
- llSetText("", <1,0,0>, 1.0);
- llSetTexture(blank, ALL_SIDES);
- }
- http_response(key request_id,integer status, list metadata, string body)
- {
- string profile_pic;
- integer s1 = llSubStringIndex(body, profile_key_prefix);
- integer s1l = profile_key_prefix_length;
- if(s1 == -1)
- { // second try
- s1 = llSubStringIndex(body, profile_img_prefix);
- s1l = profile_img_prefix_length;
- }
- if (s1 == -1)
- { // still no match?
- profile_pic = blank;
- }
- else
- {
- profile_pic = llGetSubString(body,s1 + s1l, s1 + s1l + 35);
- if (profile_pic == (string)NULL_KEY)
- {
- profile_pic = blank;
- }
- }
- llSetTexture(profile_pic, ALL_SIDES);
- }
- dataserver(key queryid, string data)
- {
- if ( data == "1" )
- {
- status = " is online";
- llSetText(owner_display_name + status, <0,1,0>, 1.0);
- }
- else if (data == "0")
- {
- status = " is offline";
- llSetText(owner_display_name + status, <1,0,0>, 1.0);
- }
- }
- touch_start(integer num_detected)
- {
- toucher = llDetectedKey(0);
- state msg;
- }
- }
- state msg
- {
- state_entry()
- {
- owner_key = llGetOwner();
- owner_name_query = llRequestDisplayName(owner_key);
- llListen(0,"",toucher,"");
- llInstantMessage(toucher, "write your message to " + owner_display_name +" - you have " +(string)time + " seconds");
- llInstantMessage(toucher, "to see " + owner_display_name +"'s profile, click this link here: secondlife:///app/agent/" + (string)user_key + "/about");
- llSetTimerEvent(time);
- }
- listen(integer ch, string name, key id, string msg)
- {
- llInstantMessage(user_key, llKey2Name(toucher) + " sent you a message from " + llGetRegionName() + ": " + msg);
- llInstantMessage(toucher, "message is sent.");
- llListenRemove(0);
- state show;
- }
- timer()
- {
- llInstantMessage(toucher, "time is up - touch again to write a message");
- llListenRemove(0);
- state show;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement