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

[Table of Contents]

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
Dreamgrid Specific Opensim Partners  

Opensim Partners

Opensim Partnership program
:REVISION: 2

Category: Dreamgrid Specific
By : Digiworldz.com
Created: 2019-03-18 Edited: 2019-03-18
Worlds: OpenSim

the Zip file

Download all files for Opensim Partners
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Opensim Partners.lsl
1 // Put this in a box. When two people touch it, they can make a partership.
2 // Mods by Ferd Frederix for Dreamgrid
3
4 // A SETTING YOU HAVE TO SET FOR SECURITY
5 // It works when blank, but it is possible for someone with this script to make or drop partners!
6
7 // Set this to your Unique grid identifier from the Settings panel.
8 string PW = "";
9
10 // CODE follows, the rest of this should probably not be modified.
11 // If you want to see a lot of messages, set this to TRUE
12 integer debug = FALSE;
13
14 // variables
15 string URL = "";
16 // Default = 8001 for Dreamgrid. :80 or blank for other grids
17 string PORT = ":8001";
18 // How long you have to convince him/her to click the box
19 float TIMEOUT = 20.0; // seconds
20
21
22 list PAR = [];
23 key id1; // 1st user
24 string name1; // 1st user
25 key id2; // 2nd user
26 string name2; // 2nd user
27 key id3; // partner of 2nd user
28 string name3; // partner of 2nd user
29
30 key http_request_id1; // get_partner; 1st user
31 key http_request_id2; // begin: get_partner; 2nd user
32 key http_request_id3; // begin: set_partner; 1st user
33 key http_request_id4; // begin: set_partner; 2nd user
34 key http_request_id5; // dissolve: set_partner; 1st user
35 key http_request_id6; // dissolve: set_partner; 2nd user
36
37
38 DEBUG(string msg) {
39 if(debug) {
40 llSay(0,msg);
41 };
42 }
43
44 string left(string src, string divider) {
45 integer index = llSubStringIndex( src, divider );
46 if(~index)
47 return llDeleteSubString( src, index, -1);
48 return src;
49 }
50 string right(string src, string divider) {
51 integer index = llSubStringIndex( src, divider );
52 if(~index)
53 return llDeleteSubString( src, 0, index + llStringLength(divider) - 1);
54 return src;
55 }
56 // default state
57 default {
58 state_entry() {
59 //Grid Gatekeeper Uri
60 URL = "http:" + left(right(osGetGridGatekeeperURI(),":"),":");
61 DEBUG(URL);
62
63 llSetText("Click here to begin or\ndissolve partnership", <1,1,1>, 1);
64 }
65 touch_start(integer num_detected) {
66 id1 = llDetectedKey(0);
67 name1 = llDetectedName(0);
68 string req = URL + PORT + "/get_partner?PW=" + PW + "&User=" + (string)id1;
69 DEBUG(req);
70 http_request_id1 = llHTTPRequest(req, PAR, "");
71 }
72
73 // called for all HTTP responses of all states
74 http_response(key request_id, integer status, list metadata, string body) {
75
76 if(request_id == http_request_id1) {
77 // get_partner; 1st user
78 DEBUG("Partner = " + body);
79 id2 = (key)body;
80 name2 = llGetDisplayName(id2);
81 if(!name2) name2 = (string)id2;
82
83 if(id2 == NULL_KEY)
84 {
85 llSay(0, name1 + ", you have no partnership at the moment");
86 state begin_partnership;
87 } else {
88 llSay(0, name1 + ", your partner is " + name2);
89 state dissolve_partnership;
90 }
91 } else if(request_id == http_request_id2) {
92 // begin: get_partner; 2nd user
93 id3 = (key)body;
94 DEBUG("Partner = " + body);
95
96 name3 = llGetDisplayName(id3);
97 if(!name3) name3 = (string)id3;
98
99 if(id3 == NULL_KEY)
100 {
101 string req = URL + PORT + "/set_partner?PW=" + PW + "&User=" + (string)id1 + "&Partner=" + (string)id2;
102 DEBUG(req);
103 http_request_id3 = llHTTPRequest(req, PAR, "");
104 } else {
105 llSay(0, name2 + ", you have " + name3 + " as partner already");
106 state default;
107 }
108 } else if(request_id == http_request_id3) {
109 // begin: set_partner; 1st user
110 string req = URL +PORT + "/set_partner?PW=" + PW + "&User=" + (string)id2 + "&Partner=" + (string)id1;
111 DEBUG(req);
112 http_request_id4 = llHTTPRequest(req, PAR, "");
113 } else if(request_id == http_request_id4) {
114 // begin: set_partner; 2nd user
115 llSay(0, name1 + " and " + name2 + " are now partners. Relog to see your new relationship status in your profiles.");
116 state default;
117 } else if(request_id == http_request_id5) {
118 // dissolve: set_partner; 2nd user
119 id2 = (key)body;
120 string req = URL+PORT + "/set_partner?PW=" + PW + "&User=" + (string)id2 + "&Partner=" + (string)NULL_KEY;
121 DEBUG(req);
122 http_request_id6 = llHTTPRequest(req, PAR, "");
123 } else if(request_id == http_request_id6) {
124 // dissolve: set_partner; 2nd user
125 llSay(0, name1 + " and " + name2 + " are not partners anymore");
126 state default;
127 } else {
128 // unknown response
129 llOwnerSay("Error: unknown response");
130 }
131 }
132 }
133
134 state begin_partnership{
135 state_entry() {
136 llSetText("Future partner of\n" + name1 + "\nplease click here", <1,1,1>, 1.0);
137 llSay(0,"Future partner of " + name1 + ", please click the box");
138 llSetTimerEvent(TIMEOUT);
139 }
140
141 timer() {
142 llSay(0, "Timeout, please try again");
143 llSetTimerEvent(0.0);
144 state default;
145 }
146
147 touch_start(integer num_detected) {
148 llSetTimerEvent(0.0);
149 id2 = llDetectedKey(0);
150 name2 = llDetectedName(0);
151
152 if((string)id1 == (string)id2)
153 {
154 llSay(0, "canceled");
155 state default;
156 }
157
158 // check if new partner has no partnership
159 string req = URL +PORT + "/get_partner?PW=" + PW + "&User=" + (string)id2;
160 DEBUG(req);
161 http_request_id2 = llHTTPRequest(req, PAR, "");
162 state default;
163 }
164 }
165
166 // dissolve partnership
167
168 state dissolve_partnership{
169 state_entry() {
170 llSetText(name1 + ", click \nif you want to dissolve\nyour current partnership", <1,1,1>, 1.0);
171 llSay(0,name1 + ", click if you want to dissolve your current partnership");
172 llSetTimerEvent(TIMEOUT);
173 }
174
175 timer() {
176 llSay(0, "Timeout, please try again");
177 llSetTimerEvent(0.0);
178 state default;
179 }
180
181 touch_start(integer num_detected) {
182 llSetTimerEvent(0.0);
183 id2 = llDetectedKey(0);
184 name2 = llDetectedName(0);
185
186 if((string)id1 != (string)id2)
187 {
188 llSay(0, "canceled");
189 state default;
190 }
191
192 string req = URL +PORT + "/set_partner?PW=" + PW + "&User=" + (string)id1 + "&Partner=" + (string)NULL_KEY;
193 DEBUG(req);
194 http_request_id5 = llHTTPRequest(req, PAR, "");
195 state default;
196 }
197 }

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