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
Rental Opensim Free Rental  

Opensim Free Rental

No Money Rental (Vendor).lsl
User can touch the sign and claim a land for a set period.
You can force them to reclaim every so often, set a grace period, and enforce a number of prims.

Category: Rental
By : Ferd Frederix
Created: 2013-09-07 Edited: 2013-09-04
Worlds: Second Life

the Zip file

Download all files for Opensim Free Rental
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Script.lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // No Money Rental (Vendor).lsl
3 // User configurable variables:
4 integer debug = FALSE; // set to TRUE to see debug info
5 // Put this in the Description of the sign prim or you will get these by default
6 // 1,7,100,1,3,1
7 // These are PERIOD in days, MAXPERIOD in days, PRIMMAX , IS_RENEWABLE, RENTWARNING ,GRACEPERIOD
8 // PERIOD == 1 day
9 // MAXPERIOD is set to 7 days, that is as long as they can lease, if IS_RENEWABLE is 0
10 // PRIMMAX is set to 100 prims, aghain, this is up to you. The script does not enforece prim limits.
11 // IS_RENEWABLE is set to 1, or TRUE, so they can renew, or set to 0, they cannot renew the same plot.
12 // RENTWARNING is number of days before this claim expires, when a message is sent via IM to reclaim (if IS_RENEWABLE)
13 // GRACEPERIOD is number of days allowed to miss claiming before it expires
14
15 string initINFO = "0.5,1,100,0,1,1"; // Default config info if you didn't change the description when this script is first executed
16 // Debug config info, 5 minutes per claim, 10 minutes max, 100 prims, 2 minute warning, grace period 1 minutes
17 //string debugINFO = "0.00347222,0.00694455,100,1,0.00138889, 0.00138889"; //fast timers
18 string debugINFO = "0.041,1,100,1,0.0104,1"; // Default config info if you didn't change the description when this script is first executed
19
20
21 // Uses several textures that need to be made and put in the prims inventory:
22 string lease_ex = "lease_ex"; // lease is expired
23 string lease_large = "lease_large"; // leased signage, large size
24 string lease_busy = "lease_busy"; // busy signage
25 string leased = "leased"; // leased - in use
26
27 vector FULL_SIZE = <1.5,.375,1.5>; // the signs size when unrented
28 vector SMALL_SIZE = <.25,.25,.25>; // the signs size when rented (it will shrink)
29 string blank_texture = "5748decc-f629-461c-9a36-a35a221fe21f"; //the UUID of a blank sign, for SL only, change to a blank white texture for OpenSim
30
31 //
32 // don't muck below this, code begins.
33 //
34 // The Description ( config info) of the sign is stored into these variables:
35
36 float PERIOD; // DAYS lease is claimed
37 integer PRIMMAX; // number of prims
38 float MAXPERIOD; // maximum length in days
39 float RENTWARNING ; //Day allowed to renew earlier
40 float GRACEPERIOD ; // Days allowed to miss payment
41
42 list my_data;
43 integer MY_STATE = 0; // 0 is unleased, 1 = leased
44 string LEASER = ""; // name of lessor
45 key LEASERID; // their UUID
46
47 integer LEASED_UNTIL; // unix time stamp
48 integer IS_RENEWABLE = FALSE; // can they renew?
49 integer DAYSEC = 86400; // a constant
50 integer SENT_WARNING = FALSE; // did they get an im?
51 integer SENT_PRIMWARNING = FALSE; // did they get an im about going over prim count?
52 integer listener; // ID for active listener
53 key touchedKey ; // the key of whoever touched us last (not necessarily the renter)
54
55
56 DEBUG(string data)
57 {
58 if(debug)
59 llOwnerSay("DEBUG: " + data);
60 }
61
62 integer dialogActiveFlag ; // true when we have up a dialog box, used by the timer to clear out the listener if no response is given
63 dialog()
64 {
65 llListenRemove(listener);
66 integer channel = llCeil(llFrand(1000000)) + 100000 * -1; // negative channel # cannot be typed
67 listener = llListen(channel,"","","");
68 llDialog(touchedKey,"Do you wish to claim this parcel?",["Yes","-","No"],channel);
70 dialogActiveFlag = TRUE;
71 }
72
73 string get_rentalbox_info()
74 {
75 return llGetRegionName() + " @ " + (string)llGetPos() + " (Leaser: \"" + LEASER + "\", Expire: " + timespan(LEASED_UNTIL - llGetUnixTime()) + ")";
76 }
77
78 string timespan(integer time)
79 {
80 integer days = time / DAYSEC;
81 integer curtime = (time / DAYSEC) - (time % DAYSEC);
82 integer hours = curtime / 3600;
83 integer minutes = (curtime % 3600) / 60;
84 integer seconds = curtime % 60;
85
86 return (string)llAbs(days) + " days, " + (string)llAbs(hours) + " hours, "
87 + (string)llAbs(minutes) + " minutes, " + (string)llAbs(seconds) + " seconds";
88
89 }
90
91 load_data()
92 {
93 integer len;
94 my_data = llCSV2List(llGetObjectDesc());
95
96 if(llStringLength(llGetObjectDesc()) < 5) // SL does not allow blank description
97 {
98 my_data = llCSV2List(initINFO);
99 }
100 else if(debug)
101 {
102 my_data = llCSV2List(debugINFO); // 5 minute fast timers
103 }
104
105 len = llGetListLength(my_data);
106
107 PERIOD = (float) llList2String(my_data,0);
108 DEBUG("PERIOD FROM DESCRIPTION " + (string) PERIOD);
109
110 MAXPERIOD = (float) llList2String(my_data,1);
111 DEBUG("MAXPERIOD FROM DESCRIPTION " + (string) MAXPERIOD);
112
113 PRIMMAX = (integer) llList2String(my_data,2);
114 DEBUG("PRIMMAX FROM DESCRIPTION : " + (string) PRIMMAX);
115
116 IS_RENEWABLE = (integer) llList2String(my_data, 3);
117 DEBUG("IS_RENEWABLE FROM DESCRIPTION : " + (string) IS_RENEWABLE);
118
119 RENTWARNING = (float) llList2String(my_data, 4);
120 DEBUG("RENTWARNING FROM DESCRIPTION : " + (string) RENTWARNING);
121
122 GRACEPERIOD = (float) llList2String(my_data, 5);
123 DEBUG("GRACEPERIOD FROM DESCRIPTION : " + (string) GRACEPERIOD);
124
125 MY_STATE = (integer) llList2String(my_data, 6);
126 DEBUG("MY_STATE FROM DESCRIPTION : " + (string) MY_STATE);
127
128 LEASER = llList2String(my_data, 7);
129 DEBUG("LEASER FROM DESCRIPTION : " + (string) LEASER);
130
131 LEASERID = (key) llList2String(my_data, 8);
132 DEBUG("LEASERID FROM DESCRIPTION : " + (string) LEASERID);
133
134 LEASED_UNTIL = (integer) llList2String(my_data, 9);
135 DEBUG("LEASED_UNTIL FROM DESCRIPTION : " + (string) LEASED_UNTIL);
136
137 SENT_WARNING = (integer) llList2String(my_data, 10);
138 DEBUG("SENT_WARNING FROM DESCRIPTION : " + (string) SENT_WARNING);
139
140 }
141
142 save_data()
143 {
144 DEBUG("Data saved in description");
145 my_data = [(string)PERIOD, (string)MAXPERIOD, (string)PRIMMAX, (string)IS_RENEWABLE, (string) RENTWARNING, (string) GRACEPERIOD, (string)MY_STATE, (string)LEASER, (string) LEASERID, (string)LEASED_UNTIL, (string)SENT_WARNING ];
147 initINFO = llList2CSV(my_data); // for debugging in LSL Editor.
148 debugINFO = initINFO; // for debugging in fast mode
149
150 load_data() ; // to print it in case of debug
151 }
152
153 default
154 {
156 {
157 load_data();
158 llSetScale(SMALL_SIZE);
159 llSetTexture(lease_ex,ALL_SIDES);
160 llOwnerSay("Click this rental box to activate after configuring the DESCRIPTION.");
161 llSetText("DISABLED",<0,0,0>, 1.0);
162 }
163
164 on_rez(integer start_param)
165 {
166 load_data();
167 }
168
169 touch_start(integer total_number)
170 {
172 {
173 load_data();
174
175 llSay(0,"Activating...");
176 if(MY_STATE == 0)
177 state unleased;
178 else if(MY_STATE == 1)
179 state leased;
180 }
181 }
182 }
183
184 state unleased
185 {
187 {
188 DEBUG("state unleased");
189 load_data();
190 if(MY_STATE !=0 || PERIOD == 0)
191 {
192 DEBUG("MY_STATE:" + (string) MY_STATE);
193 DEBUG("PERIOD:" + (string) PERIOD);
194 DEBUG("IS_RENEWABLE:" + (string) IS_RENEWABLE);
195 llOwnerSay("Returning to default. Data is not correct.");
196 state default;
197 }
198
199 llSetScale(FULL_SIZE);
200
201 //Blank texture
202 llSetTexture(blank_texture,ALL_SIDES);
203
204 llSetTexture(lease_large,1);
205 llSetTexture(lease_large,3);
206 llOwnerSay("Lease script is unleased");
207 llSetText("",<1,0,0>, 1.0);
208
209 }
210
211 listen(integer channel, string name, key id, string message)
212 {
213 dialogActiveFlag = FALSE;
215 llListenRemove(listener);
216
217 load_data();
218
219 if(message == "Yes")
220 {
221 llSay(0,"Thanks for claiming this spot! Please wait a few moments...");
222 MY_STATE = 1;
223 LEASER = llKey2Name(touchedKey);
224 LEASERID = touchedKey;
225 LEASED_UNTIL = llGetUnixTime() + (integer) (DAYSEC * PERIOD);
226 DEBUG("Remaining time:" + timespan(llGetUnixTime()-LEASED_UNTIL));
227
228 SENT_WARNING = FALSE;
229 save_data();
230 llInstantMessage(llGetOwner(), "NEW CLAIM -" + get_rentalbox_info());
231 state leased;
232 }
233 }
234
235 touch_start(integer total_number)
236 {
237 DEBUG("touch event in unleased");
238 load_data();
239 llSay(0,"Claim Info");
240
241 llSay(0, "Available for " + (string)PERIOD + " days ");
242 llSay(0, "Initial Min. Lease Time: " + (string)PERIOD + " days");
243 llSay(0, "Max Lease Length: " + (string)MAXPERIOD + " days");
244 llSay(0, "Max Prims: " + (string)PRIMMAX);
245
246 touchedKey = llDetectedKey(0);
248 dialog();
249 }
250
251 // clear out the channel listener, the menu timed out
252 timer()
253 {
254 dialogActiveFlag = FALSE;
255 llListenRemove(listener);
256 }
257 }
258
259 state leased
260 {
262 {
263 DEBUG("Leased mode");
264 DEBUG((string)llGetUnixTime());
265
266 load_data();
267 llSetScale(SMALL_SIZE);
268 llSetTexture(lease_busy,ALL_SIDES);
269 llSetText("",<1,0,0>, 1.0);
270 if(MY_STATE != 1 || PERIOD == 0 || LEASER == "")
271 {
272 DEBUG("MY_STATE:" + (string) MY_STATE);
273 DEBUG("PERIOD:" + (string) PERIOD);
274 DEBUG("LEASER:" + (string) LEASER);
275
276 MY_STATE = 0;
277 save_data();
278 llOwnerSay("Returning to unleased. Data was not correct.");
279 state unleased;
280 }
281
282 DEBUG("Remaining time:" + timespan(llGetUnixTime()-LEASED_UNTIL));
283
284 llSetTimerEvent(1); //check now
285 }
286
287 listen(integer channel, string name, key id, string message)
288 {
289 DEBUG("listen event in leased");
290 dialogActiveFlag = FALSE;
291 if(message == "Yes")
292 {
293 load_data();
294 if(MY_STATE != 1 || PERIOD == 0 || LEASER == "")
295 {
296 DEBUG("MY_STATE:" + (string) MY_STATE);
297 DEBUG("PERIOD:" + (string) PERIOD);
298 DEBUG("LEASER:" + (string) LEASER);
299
300 MY_STATE = 0;
301 save_data();
302 llSay(0,"Returning to unleased. Data is not correct.");
303 state unleased;
304 }
305 else if(IS_RENEWABLE)
306 {
307 integer timeleft = LEASED_UNTIL - llGetUnixTime();
308
309 DEBUG("Remaining time:" + timespan(llGetUnixTime()-LEASED_UNTIL));
310 DEBUG("DAYSEC:" + (string) DAYSEC);
311 DEBUG("timeleft:" + (string) timeleft);
312 DEBUG("MAXPERIOD:" + (string) MAXPERIOD);
313
314 if(DAYSEC + timeleft > MAXPERIOD * DAYSEC)
315 {
316 llSay(0,"Sorry, you can not claim more than the max time");
317 }
318 else
319 {
320 DEBUG("Leased");
321 SENT_WARNING = FALSE;
322 LEASED_UNTIL += (integer) PERIOD;
323 DEBUG("Leased until " + (string)LEASED_UNTIL );
324 save_data();
325 llSetScale(SMALL_SIZE);
326 llSetTexture(leased,ALL_SIDES);
327 llSetText("",<1,0,0>, 1.0);
328 llInstantMessage(llGetOwner(), "Renewed: " + get_rentalbox_info());
329 }
330 }
331 else
332 {
333 llSay(0,"Sorry you can not renew at this time.");
334 }
335 }
336 }
337
338 timer()
339 {
340 if(dialogActiveFlag)
341 {
342 dialogActiveFlag = FALSE;
343 llListenRemove(listener);
344 return;
345 }
346
347
348 if(!debug)
349 llSetTimerEvent(900); //15 minute checks
350 else
351 llSetTimerEvent(30); // 30 second checks for
352
353 DEBUG("timer event in leased");
354
355 load_data();
356
357 if(MY_STATE != 1 || PERIOD == 0 || LEASER == "")
358 {
359 DEBUG("MY_STATE:" + (string) MY_STATE);
360 DEBUG("PERIOD:" + (string) PERIOD);
361 DEBUG("LEASER:" + (string) LEASER);
362
363 MY_STATE = 0;
364 save_data();
365 llSay(0,"Returning to unleased. Data is not correct.");
366 state unleased;
367 }
368
370
371 if(count -1 > PRIMMAX && !SENT_PRIMWARNING) // no need to countthe sign, too.
372 {
373 llInstantMessage(LEASERID, get_rentalbox_info() + " There are supposed to be no more than " + (string)PRIMMA
374 X + " prims rezzed, yet there are "
375 +(string) count + " prims rezzed on this parcel. Plese remove the excess.");
376 llInstantMessage(llGetOwner(), get_rentalbox_info() + " There are supposed to be no more than " + (string)PRIMMA
377 X + " prims rezzed, yet there are "
378 +(string) count + " prims rezzed on this parcel, warning sent to " + LEASER );
379 SENT_PRIMWARNING = TRUE;
380 } else {
381 SENT_PRIMWARNING = FALSE;
382 }
383
384
385
386 DEBUG("Remaining time:" + timespan(llGetUnixTime()-LEASED_UNTIL));
387
388 if(IS_RENEWABLE)
389 {
390
391 DEBUG( (string) LEASED_UNTIL + " > " + (string) llGetUnixTime());
392
393 DEBUG( "RENTWARNING * DAYSEC " + (string) (RENTWARNING * DAYSEC));
394
395 if(LEASED_UNTIL > llGetUnixTime() && LEASED_UNTIL - llGetUnixTime() < RENTWARNING * DAYSEC)
396 {
397 DEBUG("Claim must be renewed");
398 llSetTexture(lease_ex,ALL_SIDES);
399 llSetText("Claim must be renewed!",<1,0,0>, 1.0);
400 }
401 else if(LEASED_UNTIL < llGetUnixTime() && llGetUnixTime() - LEASED_UNTIL < GRACEPERIOD * DAYSEC)
402 {
403 if(!SENT_WARNING)
404 {
405 DEBUG("sending warn");
406 llInstantMessage(LEASERID, "Your claim needs to be renewed, please touch the sign and claim it again! - " + get_rentalbox_info());
407 llInstantMessage(llGetOwner(), "CLAIM DUE - " + get_rentalbox_info());
408 SENT_WARNING = TRUE;
409 save_data();
410 }
411 llSetTexture(lease_ex,ALL_SIDES);
412 llSetText("CLAIM IS PAST DUE!",<1,0,0>, 1.0);
413 }
414 else if(LEASED_UNTIL < llGetUnixTime())
415 {
416 DEBUG("expired");
417 llInstantMessage(LEASERID, "Your claim has expired. Please clean up the space or contact the space owner.");
418 llInstantMessage(llGetOwner(), "CLAIM EXPIRED: CLEANUP! - " + get_rentalbox_info());
419 MY_STATE = 0;
420 save_data();
421 state default;
422
423 }
424 }
425 else if(LEASED_UNTIL < llGetUnixTime())
426 {
427 llInstantMessage(llGetOwner(), "CLAIM EXPIRED: CLEANUP! - " + get_rentalbox_info());
428 DEBUG("TIME EXPIRED. RETURNING TO DEFAULT");
429 state default;
430 }
431 }
432
433 touch_start(integer total_number)
434 {
435 DEBUG("touch event in leased");
436 load_data();
437
438 if(MY_STATE != 1 || PERIOD == 0 || LEASER == "" )
439 {
440 DEBUG("MY_STATE:" + (string) MY_STATE);
441 DEBUG("PERIOD:" + (string) PERIOD);
442 DEBUG("LEASER:" + (string) LEASER);
443
444 MY_STATE = 0;
445 save_data();
446 llSay(0,"Returning to unleased. Data is not correct.");
447 state unleased;
448 }
449
450 llSay(0,"Space currently rented by " + LEASER);
451 llSay(0,"Claim due in " + timespan(llGetUnixTime()-LEASED_UNTIL));
452
453 // same as money
454 if(llDetectedKey(0) == LEASERID && IS_RENEWABLE)
455 {
456 touchedKey = llDetectedKey(0);
457
459 }
460
461 // same as money
462 if(llDetectedKey(0) == LEASERID && !IS_RENEWABLE)
463 {
464 llSay(0,"The parcel cannot be claimed again");
465 }
466
467
468
469 }
470
471 }

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