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 No_Money_Rental_Script  

No_Money_Rental_Script

User can touch the sign and claim land for a set period.
You can force them to reclaim every so often, set a grace period, and enforce a number of prims.

You need some textures, "land available", "Land is rented", and so on. See the details in the user configuarble section of the script.

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

the Zip file

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

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