Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Online Indicator Excellent_Online_Indicator  

Excellent_Online_Indicator

Copyright © 2008 by Kristy Fanshaw
...

Category: Online Indicator
By : Kristy Fanshaw
Created: 2011-01-22 Edited: 2011-01-22
Worlds: Second Life

the Zip file

Download all files for Excellent_Online_Indicator
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Excellent_Online_Indicator_1.lsl
1 ////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2008 by Kristy Fanshaw //
3 ////////////////////////////////////////////////////////////////////////////////////////////////
4 // This program is free software: you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation, either version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // Online Indicator is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License for more details. //
13 // //
14 // To get a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. //
15 ////////////////////////////////////////////////////////////////////////////////////////////////
16
17 key user_key = "00000000-0000-0000-0000-000000000000"; // must be agent UUID whose status it will indicate
18 integer time = 30; // time within the message should be written.
19 string url = "http://world.secondlife.com/resident/";
20 key blank = TEXTURE_BLANK;
21 string name;
22 key toucher;
23 string status;
24
25 // VD 2009-11-24 workaround for WEB-1383, use <meta> instead of <img>
26 // VD 2009-11-25 try <img> if meta tag gets removed in the future
27 string profile_key_prefix = "<meta name=\"imageid\" content=\"";
28 string profile_img_prefix = "<img alt=\"profile image\" src=\"http://secondlife.com/app/image/";
29 integer profile_key_prefix_length; // calculated from profile_key_prefix in state_entry()
30 integer profile_img_prefix_length; // calculated from profile_img_prefix in state_entry()
31
32 //string profile_key_prefix = "<meta name=\"imageid\" content=\"";
33 //integer s1l;
34
35 default
36 {
38 {
39 profile_key_prefix_length = llStringLength(profile_key_prefix);
40 profile_img_prefix_length = llStringLength(profile_img_prefix);
41 llSetText("", <1,0,0>, 1.0);
42 llSetTexture(blank, ALL_SIDES);
43 llRequestAgentData( user_key, DATA_NAME);
44 }
45 dataserver(key queryid, string data)
46 {
47 name = data;
48 llSetObjectName(name + "'s Online Detector");
49 state show;
50 }
51 }
52 state show
53 {
55 {
57 }
58 timer()
59 {
60 llHTTPRequest( url + (string)user_key,[HTTP_METHOD,"GET"],"");
62 }
63 on_rez(integer start_param)
64 {
65 llSetText("", <1,0,0>, 1.0);
66 llSetTexture(blank, ALL_SIDES);
67 }
68 http_response(key request_id,integer status, list metadata, string body)
69 {
70 string profile_pic;
71 integer s1 = llSubStringIndex(body, profile_key_prefix);
72 integer s1l = profile_key_prefix_length;
73 if(s1 == -1)
74 { // second try
75 s1 = llSubStringIndex(body, profile_img_prefix);
76 s1l = profile_img_prefix_length;
77 }
78
79 if(s1 == -1)
80 { // still no match?
81 profile_pic = blank;
82 }
83 else
84 {
85 profile_pic = llGetSubString(body,s1 + s1l, s1 + s1l + 35);
86 if(profile_pic == (string)NULL_KEY)
87 {
88 profile_pic = blank;
89 }
90 }
91 llSetTexture(profile_pic, ALL_SIDES);
92 }
93
94
95 dataserver(key queryid, string data)
96 {
97 if( data == "1" )
98 {
99 status = " is online";
100 llMessageLinked(2, 16, "Turn On", ""); /// added for child script
101 llSetText(name + status, <0,1,0>, 1.0);
102 }
103 else if(data == "0")
104 {
105 status = " is offline";
106 llMessageLinked(2, 16, "Turn Off", ""); // added for child script
107 llSetText(name + status, <1,0,0>, 1.0);
108 }
109
110 }
111 touch_start(integer num_detected)
112 {
113 toucher = llDetectedKey(0);
114 state msg;
115 }
116 }
117 state msg
118 {
120 {
121 llListen(0,"",toucher,"");
122 llInstantMessage(toucher, "write your message to " + name +" - you have " +(string)time + " seconds");
123 llInstantMessage(toucher, "to see " + name +"'s profile, click this link here: secondlife:///app/agent/" + (string)user_key + "/about");
124 llSetTimerEvent(time);
125 }
126 listen(integer ch, string name, key id, string msg)
127 {
128 llInstantMessage(user_key, llKey2Name(toucher) + " sent you a message from " + llGetRegionName() + ": " + msg);
129 llInstantMessage(toucher, "message is sent.");
131 state show;
132 }
133 timer()
134 {
135 llInstantMessage(toucher, "time is up - touch again to write a message");
137 state show;
138 }
139 }

Back to the Best Free Tools in Second Life and OpenSim.