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 Rental_Controller  

Rental_Controller

Rental_Controller

Category: Rental
By : phoenix Behemoth
Created: 2013-04-21 Edited: 2013-04-21
Worlds: Second Life

the Zip file

Download all files for Rental_Controller
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Rental_Controller_1.lsl
1 // this is an open source project and should be given out
2
3 // full permissions for no more than L$10 to recoup land fees
4
5 // Created By phoenix Behemoth
6
7 //----------------------------------------------------------------
8
9 integer messagestoper;
10 integer timersteps = 60;
11 list splitwith;
12 list splitname;
13 string ownername;
14 integer not_registered = TRUE;
15 vector original_location;
16 vector original_scale;
17 integer objects = 150; // objects
18 float price = 10; // price
19 integer weeks = 1; // weaks
20 vector offset = <0, 0, 0>;
21 integer mature = 0;
22 string rentor;
23 key rentorkey;
24 integer rented = FALSE;
25 string rentperiod;
26 integer numListen;
27 integer randchannel;
28 integer editmode;
29 integer stopper;
30 string daterented;
31 integer rentedweeks;
32 integer timerevent;
33 integer errorcount;
34 string resident;
35 key requestid;
36 string httpfor;
37 list editmenu = ["Price","Weeks","Prims","Offset","Renter","Rented For","Split"];
38 list edittextmessage = ["Please type the price into the box below","Please type the minimum amount of weeks that can be put on","Please type the prim limit for this unit","Please type the offset in formated like <0,0,2> would make it go to 2m above when rented","Please type the name you want to rent case sensative","Please type in the box formated like days:hours:mins:seconds","To add put +username to remove -username"];
39 string editpromt = "";
40
41 rented_fltext()
42 {
43 llSetText("Rented By: "+rentor+"\nTime Left:"+rentedval(0),<1,1,1>,1);
44 }
45
46 string rentedval(integer type)
47 {
48 integer weeks2;
49 weeks2 = timerevent / 7 / 24 / 60 / 60;
50 integer days;
51 days = timerevent / 24 / 60 / 60 - (weeks2 * 7);
52 integer hours;
53 hours = timerevent / 60 / 60 - (weeks2 * 7 * 24) - (days * 24);
54 integer mins;
55 mins = timerevent / 60 - (weeks2 * 7 * 24 * 60) - (days * 24 * 60) - (hours * 60);
56 integer seconds;
57 seconds = timerevent - (weeks2 * 7 * 24 * 60 * 60) - (days * 24 * 60 * 60) - (hours * 60 * 60) - (mins * 60);
58 if(type == 1)
59 {
60 return (string)weeks2 + " weeks | " + (string)days + " days | " + (string)hours + ":" + (string)mins + ";" +(string)seconds;
61 }else
62 {
63 return (string)weeks2+" Weeks "+(string)days+" Days\n"+(string)hours+" Hours "+(string)mins+" Mins";
64 }
65 }
66
67 unrented_fltext()
68 {
69 llSetText("Price Per Week: L$"+(string)llCeil(price)+"\n Prims: "+(string)objects+"\nMinumum Weeks: "+(string)weeks,<1,1,1>,1);
70 }
71
72 clear_data()
73 {
74 string objectname;
75 objectname = llGetObjectName();
76 llSetTexture("rentit", ALL_SIDES);
77 llSetPos(original_location);
78 llSetScale(original_scale);
79 llListenRemove(numListen);
80 numListen = llListen(0, "", "", "" );
81 rentperiod = "";
82 rentor = "";
83 rentorkey = NULL_KEY;
84 rented = FALSE;
85 daterented = "";
86 rentedweeks = 0;
87 timerevent = 0;
89 llSay(0, objectname + " is vacent");
90 unrented_fltext();
91 }
92
93 default
94 {
96 {
97 llSetText("",<1,1,1>,1);
99 errorcount = 0;
100 editmode = 0;
101 randchannel = (integer)llFrand(10000000);
102 llWhisper(0, "Activating...");
103 ownername = llKey2Name(llGetOwner());
104 llWhisper(0, "Asking for permission from owner " + ownername + ".(for refunds on incorect amount only)");
106 original_location = llGetPos();
107 original_scale = llGetScale();
108 rentedweeks = 0;
109 llListen(randchannel,"","","");
110 timerevent = 0;
111 }
112 on_rez(integer change)
113 {
115 }
117 {
118 if(type == PERMISSION_DEBIT)
119 {
120 ownername = llKey2Name(llGetOwner());
121 llWhisper(0, "This space is now available for rent.");
122 not_registered = FALSE;
123 llSetPayPrice(PAY_DEFAULT,[llCeil(price * weeks),llCeil(price * weeks * 2),llCeil(price * weeks * 3),llCeil(price * weeks * 4),llCeil(price * weeks * 5),llCeil(price * weeks * 6)]);
124 unrented_fltext();
125 state running;
126 }
127 else
128 {
129 errorcount ++;
130 if(errorcount == 1)
131 {
132 llOwnerSay("permissions are required to give refunds and give change this unit will not work without them ");
133 llOwnerSay("second chance if you dont agree this time this unit will not work till next rez");
135 }
136 }
137 }
138 }
139
140 state running
141 {
142 on_rez(integer change)
143 {
145 }
146 listen(integer c, string n, key id, string m)
147 {
148 stopper = 0;
149 string objectname;
150 objectname = llGetObjectName();
151 if(m == "Free Rent" && price == 0)
152 {
153 timerevent += (604800*weeks);
154 rentor = llKey2Name(id);
155 rentorkey = id;
156 rented = TRUE;
157 rented_fltext();
158 llWhisper(0, "Prim limit is "+(string)objects+" prims.");
159 llWhisper(0, "Keep prim limits or risk termination of agreement.Rent is non-refundable. IM " + ownername + " with questions.");
160 llWhisper(0, "Thank you for renting this space . Thank You For Purchasing "+(string)weeks+" weeks . Feel Free To Put Your stuff in now");
161 }
162 if(editpromt != "")
163 {
164 // text imput from dialog
165 if(m == "")
166 {
167 m = "Edit";
168 }
169 else
170 {
171 //price ----------------------
172 if(editpromt == "Price")
173 {
174 price = (float)m;
175 llOwnerSay("Price set to L$" + (string)llCeil(price));
176 if(price > 0)
177 {
178 llSetPayPrice(PAY_DEFAULT,[llCeil(price * weeks),llCeil(price * weeks * 2),llCeil(price * weeks * 3),llCeil(price * weeks * 4),llCeil(price * weeks * 5),llCeil(price * weeks * 6)]);
179 }
180 else
181 {
183 }
184
185 if(~rented)
186 {
187 unrented_fltext();
188 }
189 }
190
191 // Renter ------------------
192
193 if(editpromt == "Renter")
194 {
195
196 rentor = m;
197 llOwnerSay("renter set to " + rentor);
198 httpfor = "rentor";
199 requestid = llHTTPRequest("http://w-hat.com/name2key?terse=1&name="+llEscapeURL(rentor),[HTTP_METHOD,"GET"],"");
200 }
201
202 // Prims ---------------------
203
204 if(editpromt == "Prims")
205 {
206 objects = (integer)m;
207 llOwnerSay("Prims set to " + (string)objects);
208
209 if(~rented)
210 {
211 unrented_fltext();
212 }
213 }
214
215 // Weeks ---------------------
216 if(editpromt == "Weeks")
217 {
218 weeks = (integer)m;
219 llOwnerSay("weeks set to " + (string)weeks);
220 llSetPayPrice(PAY_DEFAULT,[llCeil(price * weeks),llCeil(price * weeks * 2),llCeil(price * weeks * 3),llCeil(price * weeks * 4),llCeil(price * weeks * 5),llCeil(price * weeks * 6)]);
221 if(~rented)
222 {
223 unrented_fltext();
224 }
225 }
226
227 // Split ---------------------
228
229 if(llGetSubString(m,0,0) == "+" && editpromt == "Split")
230 {
231 string namex = llGetSubString(m,1,-1);
232 splitname +=namex;
233 resident = namex;
234 requestid = llHTTPRequest("http://w-hat.com/name2key?terse=1&name="+llDumpList2String(llParseString2List(namex,[" "],[]),"+"),[HTTP_METHOD,"GET"],"");
235 }
236
237 if(llGetSubString(m,0,0) == "-" && editpromt == "Split")
238 {
239
240 string name = llGetSubString(m,1,-1);
241 integer finddata = llListFindList(splitname,(list)name);
242 if(finddata == -1)
243 {
244 llSay(0,"sorry " + name + " not found");
245 }
246 else
247 {
248 splitwith = llDeleteSubList(splitwith,finddata,finddata);
249 splitname =llDeleteSubList(splitname,finddata,finddata);
250 llSay(0,name +" removed from shared list");
251 }
252
253 }
254 // Offset -----------------------
255 if(editpromt == "Offset")
256 {
257 offset = (vector)m;
258 llOwnerSay("Offset set to " + (string)offset);
259 }
260 }
261
262 // Rented For--------------------
263
264 if(editpromt == "Rented For")
265 {
266 string date = llGetTimestamp();
267 daterented = llGetSubString(date,5,6) + "/" + llGetSubString(date,8,9) + "/" + llGetSubString(date,0,3) + " | Time " + llGetSubString(date,11,15);
268 original_scale = llGetScale();
269 original_location = llGetPos();
270 list renttime = llParseStringKeepNulls(m, [":"], []);
271 integer days = llList2Integer(renttime,0);
272 integer hours = llList2Integer(renttime,1);
273 integer minites = llList2Integer(renttime,2);
274 integer seconds = llList2Integer(renttime,3);
275 integer total;
276 total = (days * 24 * 60 * 60) + (hours * 60 * 60) + (minites * 60) + (seconds);
277 llSetTexture("info", ALL_SIDES);
278 llSetPos(original_location + offset);
279 llSetScale(<0.236,0.236,0.236>);
280 timerevent = total;
281 llSetTimerEvent(timersteps);
282 llWhisper(0,"set to " + (string)days + " days " + (string)hours + " hours " + (string)minites + " mins " + (string)seconds + " seconds");
283 rented = TRUE;
284 llSetText("",<1,1,1>,1);
285 }
286 }
287
288 if(llListFindList(editmenu,[m]) != -1)
289 {
290 editpromt = m;
291 if(editpromt != "Split")
292 {
293 llTextBox(llGetOwner(),llList2String(edittextmessage,llListFindList(editmenu,[m])),randchannel);
294 }else
295 {
296 llTextBox(llGetOwner(),llList2String(edittextmessage,llListFindList(editmenu,[m]))+"\n current split:\n"+llDumpList2String(splitname,"\n"),randchannel);
297 }
298 }
299
300 if(m == "Vacent" && c == randchannel && id == llGetOwner() && rented == TRUE)
301 {
302 clear_data();
303 }
304 if(m == "Mature" && c == randchannel && id == llGetOwner())
305 {
306 mature = 1;
307 llOwnerSay("set to Mature Area");
308 }
309 if(m == "Renter info" && c == randchannel && id == llGetOwner())
310 {
311 llOwnerSay("Rented Date: " + daterented);
312 llOwnerSay("Rented Left: " + rentedval(1));
313 if(rentedweeks >= 2)
314 {
315 llOwnerSay("Rented amount: " + (string)rentedweeks + " weeks");
316 }
317 if(rentedweeks == 1)
318 {
319 llOwnerSay("Rented amount: " + (string)rentedweeks + " week");
320 }
321 if(rentedweeks <= 0)
322 {
323 llOwnerSay("Rented amount: N/A");
324 }
325
327 integer prims = 0;
328 integer count = llGetListLength(keys);
329 if(count == 0)
330 {
331 prims = -1;
332 }
333
334 integer no;
335
336 for(no = 0 ;no < count;no ++)
337 {
338 if(rentorkey == (key)llList2String(keys,no))
339 {
340 prims = (integer)llList2String(keys,no + 1);
341 }
342 }
343 if(prims != -1)
344 {
345 llOwnerSay("Current Prims are "+(string)prims+" out of "+(string)objects);
346 }else
347 {
348
349 llOwnerSay("Current Prims are ??(as land is not owned) out of "+(string)objects);
350 }
351 }
352
353 if(m == "PG" && c == randchannel && id == llGetOwner())
354 {
355 mature = 0;
356 llOwnerSay("set to PG Area");
357 }
358
359 if(m == "Status" && c == randchannel && id == llGetOwner())
360 {
361 string mit;
362 llOwnerSay("Prim's set to " + (string)objects);
363 llOwnerSay("Week's set to " + (string)weeks);
364 llOwnerSay("Offset set to " + (string)offset);
365 llOwnerSay("Price is set to " + (string)price + "L$ per week");
366 if(mature == 1)
367 {
368 mit = "Yes";
369 }
370 else
371 {
372 mit = "No";
373 }
374
375 llOwnerSay("Regen Mature: " + (string)mit);
376 }
377
378 if(m == "Edit" && stopper == 0 && c == randchannel && id == llGetOwner())
379 {
380 editpromt = "";
381 stopper = 1;
382 llDialog(llGetOwner(),"vender editor\nEdit",["Back"]+editmenu,randchannel);
383 }
384
385 if(m == "Back")
386 {
387 llDialog(llGetOwner(),"vender editor ",["Mature","PG","Vacent","Edit","Renter info","Help","Status"],randchannel);
388 }
389
390 if(m == "Help" && c == randchannel && id == llGetOwner())
391 {
392 llGiveInventory(llGetOwner(), "Rentals Help");
393 }
394
395
396 if(llGetSubString(m,0,9) == "set timer " && id==llGetOwner())
397 {
398 timersteps = (integer)llGetSubString(m,9,llStringLength(m));
399 llOwnerSay("timer steps =" + (string)timersteps + " seconds");
400 if(rented == TRUE)
401 {
402 llSetTimerEvent(timersteps);
403 }
404 }
405 }
406
408 {
409 llOwnerSay("Touch For Menu");
410 numListen = llListen(0, "", "", "" );
411 llListen(randchannel,"","","");
412 }
413
414
415 timer() {
416 timerevent-= timersteps;
417 rented_fltext();
418 if(timerevent >= 1)
419 {
420 }
421
422 if(timerevent <= 172800 && messagestoper == 0 && rentorkey != NULL_KEY)
423 {
424 messagestoper = 1;
425 llInstantMessage(rentorkey,"Your rental at " + llGetRegionName() + " has 2 days");
426 }
427
428 if(timerevent <= 86400 && messagestoper == 1 && rentorkey != NULL_KEY)
429 {
430 messagestoper = 2;
431 llInstantMessage(rentorkey,"Your rental at " + llGetRegionName() + " is on its last day");
432 }
433
434 else if(timerevent <= 0)
435 {
436 llInstantMessage(llGetOwner(),"rental at "+llGetRegionName()+":"+(string)llGetPos()+" has expired");
437 if(rentorkey != NULL_KEY)
438 {
439 llInstantMessage(rentorkey,"Your rental at " + llGetRegionName() + " has expired");
440 messagestoper = 0;
441 }
442 llSay(0,"rental expired");
443 clear_data();
444 }
445 }
446
447
448 touch_start(integer total_number)
449 {
451 {
452 llDialog(llGetOwner(),"vender editor ",["Mature","PG","Vacent","Edit","Renter info","Help","Status"],randchannel);
453 }
454 else
455 {
456 if(rented == FALSE)
457 {
458 list options = ["Close"];
459 if(price == 0)options += "Free Rent";
460 llDialog(llDetectedKey(0),"This space is for rent. The price is $" +(string)price+ " per week. Prim limit is "+(string)objects+" prims. Obey prim limits to avoid termination of agreement. Rent is non-refundable.",options,randchannel);
461
462 if(mature == 1)
463 {
464 llWhisper(0, "Usage Restrictions:Keep within prim limits or face termination of lease.");
465 } else
466 {
467 llWhisper(0, "Usage Restrictions: Keep within prim limits or face termination of lease. Keep To PG Rules as in PG Sim");
468 }
469
470 llWhisper(0, "Right click and pay to rent this space. Minimum rental period is "+(string)weeks+" weeks, at $" +(string)(price*weeks)+". If you have any questions, please feel free to IM " + ownername + ". For Help please IM " + ownername + ".");
471 }
472 else
473 {
475 integer prims = 0;
476 integer count = llGetListLength(keys);
477 if(count == 0)
478 {
479 prims = -1;
480 }
481
482 integer no;
483 for(no = 0 ;no < count;no ++)
484 {
485 if(rentorkey == (key)llList2String(keys,no))
486 {
487 prims = (integer)llList2String(keys,no + 1);
488 }
489 }
490
491 string addon;
492 if( prims != -1)
493 {
494 addon = "Current Prims are "+(string)prims+" out of "+(string)objects;
495 }else
496 {
497 addon = "Max prims are " + (string)objects;
498 }
499 llDialog(llDetectedKey(0),"This space is occupied by " + rentor + " for "+rentedval(1)+ "\n\n"+addon + ". For help please IM " + ownername + ".",["OK"],-1);
500
501 }
502
503 }
504
505 }
506
507
508
509 money(key giver, integer amount)
510 {
511 integer amount2 = amount%(integer)price;
512 integer weeks = amount/(integer)price;
513 if(amount>=price*weeks && amount2==0 && rented == FALSE)
514 {
515 if(~rented)
516 {
517 llSetText("",<1,1,1>,1);
518 }
519 rentedweeks = amount/(integer)price;
520 string date = llGetTimestamp();
521 daterented = llGetSubString(date,5,6) + "/" + llGetSubString(date,8,9) + "/" + llGetSubString(date,0,3) + " | Time " + llGetSubString(date,11,15);
522 original_scale = llGetScale();
523 original_location = llGetPos();
524 timerevent = 604800*weeks;
525 rentor = llKey2Name(giver);
526 rented = TRUE;
527 rentperiod = (string)weeks;
528 llWhisper(0, "Prim limit is "+(string)objects+" prims.");
529 llWhisper(0, "Keep prim limits or risk termination of agreement.Rent is non-refundable. IM " + ownername + " with questions.");
530 llWhisper(0, "Thank you for renting this space . Thank You For Purchasing "+(string)weeks+" weeks . Feel Free To Put Your stuff in now");
531 llSetTexture("info", ALL_SIDES);
532 llSetPos(original_location + offset);
533 llSetScale(<0.236,0.236,0.236>);
534 rented_fltext();
535 rentorkey = giver;
536 llSetTimerEvent(timersteps);
537 if(splitwith != [])
538 {
539 integer devide = llGetListLength(splitwith) + 1;
540 integer totatogive = amount/devide;
541 integer no;
542 rented_fltext();
543 while(no < llGetListLength(splitwith))
544 {
545 if(amount >= devide)
546 {
547 key dest = llList2Key(splitwith,no);
548 llGiveMoney(dest,totatogive);
549 llInstantMessage(dest,"you have bee payed L$"+ (string)totatogive +" by " + llGetObjectName());
550 }else
551 {
552 key dest = llList2Key(splitwith,no);
553
554 llInstantMessage(dest,"Sorry not anough money to pay you has come into renter " + llGetObjectName());
555
556 }
557 no ++;
558 }
559 }
560 }
561 else if(rented == TRUE)
562 {
563 if(llKey2Name(giver) == rentor && amount>=price*weeks && amount2==0)
564 {
565 timerevent += (604800*weeks);
566 llSay(0, "you have incresed your rental by " + (string)weeks + " weeks");
567 rentedweeks += weeks;
568 messagestoper = 0;
569 if(splitwith != [])
570 {
571 integer devide = llGetListLength(splitwith) + 1;
572 integer totatogive = amount/devide;
573 integer no;
574 while(no < llGetListLength(splitwith))
575 {
576 if(amount >= devide)
577 {
578 key dest = llList2Key(splitwith,no);
579 llGiveMoney(dest,totatogive);
580 llInstantMessage(dest,"you have bee payed L$"+ (string)totatogive +" by " + llGetObjectName());
581 }else
582 {
583 key dest = llList2Key(splitwith,no);
584 llInstantMessage(dest,"Sorry not anough money to pay you has come into renter " + llGetObjectName());
585 }
586 no ++;
587 }
588 }
589 }
590 else
591 {
592 llGiveMoney(giver, amount);
593 llSay(0,"sorry please check rental");
594 }
595 }
596 else
597 {
598 llWhisper(0, "Minimum rental period is "+(string)weeks+" weeks, at $" +(string)(price*weeks)+ ". If you have any questions, please feel free to IM" + ownername + ".");
599 llWhisper(0, "Giving money back.");
600 llGiveMoney(giver, amount);
601 }
602 }
603
604 http_response(key request_id, integer status, list metadata, string body)
605 {
606 if(request_id == requestid)
607 {
608 if((key)body != NULL_KEY)
609 {
610 if(httpfor =="rentor")
611 {
612 httpfor = "";
613 rentorkey = body;
614 }else
615 {
616 splitwith += body;
617 llSay(0,"Split Added with: \""+resident+"\"");
618
619 }
620 }
621 else
622 {
623 splitname = llDeleteSubList(splitname,-1,-1);
624 llSay(0,"No resident named \""+resident+"\" found in the w-hat name2key database");
625 }
626
627 } else
628 {
629 splitname= llDeleteSubList(splitname,-1,-1);
630 llSay(0,(string)status+" error");
631 }
632 }
633 }
634
635

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