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_Vendor  

Rental_Vendor

Rental (Vendor).lsl

Category: Rental
By : Anonymous
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Rental_Vendor
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Rental_Vendor_1.lsl
1 // mods on 1/10/2013 to fix this for inworldz
2 //Put this in the Description of the prim:
3 // 100,1,7,100,1
4 // These are RATE,PERIOD, MAXPERIOD, PRIMMAX, IS_RENEWABLE
5
6 // RATE ==100 Lindens a day
7 // PERIOD == 1 day
8 // MAXPERIOD is set to 7 days, that is as long as they can lease
9 // PRIMMAX is set to 100 prims
10 // IS_RENEWABLE is set to 1, or TRUE, so they can renew
11
12 //Uses several textures that need to be made and put in the prims inventory:
13 //lease-ex - lease expired
14 //lease-large - leased signage
15 //lease-question - busy signage
16 //bayhill-question - in use
17
18 list my_data;
19 integer MY_STATE =0;
20 string LEASER = "";
21 key LEASERID;
22 integer RATE =0;
23 integer PERIOD =0; //DAYS
24 integer PRIMMAX =0;
25 integer MAXPERIOD =0;
26 integer CHANNEL = 192;
27 integer CREDIT = 0;
28 integer LEASED_UNTIL = 0;
29 integer IS_RENEWABLE = FALSE;
30 integer can_renew = FALSE;
31 integer DAYSEC = 86400;
32 integer SENT_WARNING = FALSE;
33 integer RENTWARNING = 3; //Day allowed to renew earlier
34 integer GRACEPERIOD = 3; // Days allowed to miss payment
35 vector FULL_SIZE = <1.5,.375,1.5>;
36 vector SMALL_SIZE = <.25,.25,.25>;
37 integer INIT = FALSE;
38
39 DEBUG(string data)
40 {
41 llOwnerSay("DEBUG: " + data);
42 }
43
44 string get_rentalbox_info()
45 {
46 return llGetRegionName() + " @ " + (string)llGetPos() + " (Leaser: \"" + LEASER + "\", Expire: " + timespan(LEASED_UNTIL - llGetUnixTime()) + ")";
47 }
48
49 string timespan(integer time)
50 {
51
52 integer days = time / DAYSEC;
53 integer curtime = (time / DAYSEC) - (time % DAYSEC);
54 integer hours = curtime / 3600;
55 integer minutes = (curtime % 3600) / 60;
56 integer seconds = curtime % 60;
57
58 return (string)llAbs(days) + " days, " + (string)llAbs(hours) + " hours, "
59 + (string)llAbs(minutes) + " minutes, " + (string)llAbs(seconds) + " seconds";
60
61 }
62
63 load_data()
64 {
65 integer len;
66 my_data = llCSV2List(llGetObjectDesc());
67 len = llGetListLength(my_data);
68 RATE = (integer) llList2String(my_data,0);
69 PERIOD = (integer) llList2String(my_data,1);
70 MAXPERIOD = (integer) llList2String(my_data,2);
71 PRIMMAX = (integer) llList2String(my_data,3);
72 IS_RENEWABLE = (integer) llList2String(my_data, 4);
73 MY_STATE = (integer) llList2String(my_data, 5);
74 LEASER = llList2String(my_data, 6);
75 LEASERID = llList2Key(my_data, 7);
76 CREDIT = (integer) llList2String(my_data, 8);
77 LEASED_UNTIL = (integer) llList2String(my_data, 9);
78 SENT_WARNING = (integer) llList2String(my_data, 10);
79 }
80
81 save_data()
82 {
83 my_data = [RATE,PERIOD, MAXPERIOD, PRIMMAX, IS_RENEWABLE, MY_STATE, LEASER, LEASERID, CREDIT, LEASED_UNTIL, SENT_WARNING];
84 llSetObjectDesc(llList2CSV(my_data));
85 }
86
87 default
88 {
90 {
91 if(!INIT)
92 {
94 INIT = TRUE;
95 }
96 load_data();
97 llSetScale(SMALL_SIZE);
98 llSetTexture("lease-ex",ALL_SIDES);
99 llOwnerSay("Click this rental box to activate after configuring.");
100 llSetText("DISABLED",<0,0,0>, 1.0);
101 }
102
103 on_rez(integer start_param)
104 {
105 load_data();
106 }
107
108 money(key giver, integer ammount)
109 {
110 llWhisper(0,"Unable to accept money right now");
111 llGiveMoney(giver,ammount);
112 }
113
114 touch_start(integer total_number)
115 {
117 {
118 load_data();
119 if(PERIOD == 0 || RATE ==0 || (!IS_RENEWABLE && LEASED_UNTIL < llGetUnixTime()))
120 {
121 llSay(0,"This space is not currently purchasble or requires configuration.");
122 }
123 else
124 {
125 llSay(0,"Activating...");
126 if(MY_STATE == 0)
127 state unleased;
128 else if(MY_STATE == 1)
129 state leased;
130 }
131 }
132 }
133 }
134
135 state unleased
136 {
138 {
139 load_data();
140 if(MY_STATE !=0 || PERIOD == 0 || RATE == 0 || !IS_RENEWABLE)
141 {
142 llOwnerSay("Returning to default. Data might not be correct.");
143 state default;
144 }
145 llSetScale(FULL_SIZE);
146 //Blank texture
147 llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
148 llSetTexture("lease-large",1);
149 llSetTexture("lease-large",3);
150 llOwnerSay("Lease script is active...");
151 llSetText("",<1,0,0>, 1.0);
152
153 }
154
155 money(key giver, integer ammount)
156 {
157 load_data();
158 if(ammount < RATE * PERIOD)
159 {
160 llSay(0,"Sorry, you didn't pay anough.");
161 llGiveMoney(giver, ammount);
162 }
163 else if(ammount > MAXPERIOD * RATE)
164 {
165 llSay(0,"Sorry, you payed more then the max allows.");
166 llGiveMoney(giver, ammount);
167 }
168 else
169 {
170 llSay(0,"Thanks for renting! Please wait a few moments...");
171 MY_STATE = 1;
172 LEASER = llKey2Name(giver);
173 LEASERID = giver;
174 if((ammount % RATE) != 0)
175 {
176 llSay(0,"oops, you overpaid. Here is a partial refund");
177 llGiveMoney(giver,(ammount % RATE));
178 }
179 CREDIT = (ammount - (ammount % RATE))/RATE;
180 LEASED_UNTIL = llGetUnixTime() + (CREDIT * DAYSEC);
181 SENT_WARNING = FALSE;
182 save_data();
183 llInstantMessage(llGetOwner(), "NEW LEASE - $" + (string)(ammount - (ammount % RATE)) + "L - " + get_rentalbox_info());
184 state leased;
185 }
186
187 }
188
189 touch_start(integer total_number)
190 {
191 load_data();
192 llSay(0,"Bay Hills Lease");
193 //llSay(0,"Only $L" + (string)RATE + " per day");
194 llSay(0, "Only $L" + (string)(RATE * PERIOD) + " for " + (string)PERIOD + " days ($L" + (string)RATE + " per day)");
195 llSay(0, "Initial Min. Lease Time: " + (string)PERIOD + " days");
196 llSay(0, "Max Lease Payment Length: " + (string)MAXPERIOD + " days");
197 llSay(0, "Max Prims: " + (string)PRIMMAX);
199 }
200 }
201
202 state leased
203 {
205 {
206 DEBUG("Leased mode");
207 DEBUG((string)llGetUnixTime());
208
209 load_data();
210 llSetScale(SMALL_SIZE);
211 llSetTexture("lease-question",ALL_SIDES);
212 llSetText("",<1,0,0>, 1.0);
213 if(MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
214 {
215 MY_STATE = 0;
216 save_data();
217 llOwnerSay("Returning to unleased. Data might not be correct.");
218 state unleased;
219 }
220 llSetTimerEvent(900); //15 minute checks
221
222 }
223
224 money(key giver, integer ammount)
225 {
226 load_data();
227 if(MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
228 {
229 MY_STATE = 0;
230 save_data();
231 llSay(0,"Returning to unleased. Data might not be correct.");
232 llGiveMoney(giver,ammount);
233 state unleased;
234 }
235
236 if(llGetOwner() != giver && giver != LEASERID)
237 {
238 llSay(0,"Well thats nice that you want to pay this rent but only the leaser may do so.");
239 llGiveMoney(giver,ammount);
240 }
241
242 else if(IS_RENEWABLE || llGetOwner() == giver)
243 {
244
245 integer timeleft = LEASED_UNTIL - llGetUnixTime();
246 integer curammount = (ammount - (ammount % RATE))/RATE; //Caculated sum after refund
247
248 if(((curammount * DAYSEC) + timeleft) > MAXPERIOD * DAYSEC)
249 {
250 llSay(0,"Sorry, you can not purchase more then the max time");
251 llGiveMoney(giver,ammount);
252 }
253 //**
254 //** - Not going to punish anyone right now after they sigh up. let them pay day by day
255 //**
256 //else if(((curammount * DAYSEC) + timeleft) < PERIOD * DAYSEC)
257 //{
258 // llSay(0,"You have to pay anough to meet the min time");
259 // llGiveMoney(giver,ammount);
260 //}
261 else
262 {
263
264 //Refund code
265 if((ammount % RATE) != 0)
266 {
267 llSay(0,"oops, you overpaid. Here is a partial refund");
268 llGiveMoney(giver,(ammount % RATE));
269 }
270 CREDIT = curammount;
271 SENT_WARNING = FALSE;
272 LEASED_UNTIL += (curammount * DAYSEC);
273 save_data();
274 llSetScale(SMALL_SIZE);
275 llSetTexture("bayhill-question",ALL_SIDES);
276 llSetText("",<1,0,0>, 1.0);
277 llInstantMessage(llGetOwner(), "LEASE CREDIT - $" + (string) (curammount * RATE) + "L - " + get_rentalbox_info());
278 }
279 }
280 else
281 {
282 llGiveMoney(giver,ammount);
283 llSay(0,"Sorry you can not renew at this time.");
284 }
285
286 }
287
288 timer()
289 {
290 load_data();
291 if(MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
292 {
293 MY_STATE = 0;
294 save_data();
295 llSay(0,"Returning to unleased. Data might not be correct.");
296 state unleased;
297 }
298
299 if(IS_RENEWABLE)
300 {
301 if(LEASED_UNTIL > llGetUnixTime() && LEASED_UNTIL - llGetUnixTime() < RENTWARNING * DAYSEC)
302 {
303 llSetTexture("lease-ex",ALL_SIDES);
304 llSetText("Rent Due!",<1,0,0>, 1.0);
305 }
306 else if(LEASED_UNTIL < llGetUnixTime() && llGetUnixTime() - LEASED_UNTIL < GRACEPERIOD * DAYSEC)
307 {
308 if(!SENT_WARNING)
309 {
310 llInstantMessage(LEASERID, "Your rent is due! - " + get_rentalbox_info());
311 llInstantMessage(llGetOwner(), "RENT DUE - " + get_rentalbox_info());
312 SENT_WARNING = TRUE;
313 save_data();
314 }
315 llSetTexture("lease-ex",ALL_SIDES);
316 llSetText("RENT PAST DUE!",<1,0,0>, 1.0);
317 }
318 else if(LEASED_UNTIL < llGetUnixTime())
319 {
320 llInstantMessage(LEASERID, "Your lease has expired. Please clean up the space or contact the space owner.");
321 llInstantMessage(llGetOwner(), "LEASE EXPIRED: CLEANUP! - " + get_rentalbox_info());
322 MY_STATE = 0;
323 save_data();
324 state default;
325
326 }
327 }
328 else if(LEASED_UNTIL < llGetUnixTime())
329 {
330 llInstantMessage(llGetOwner(), "LEASE EXPIRED: CLEANUP! - " + get_rentalbox_info());
331 DEBUG("TIME EXPIRED. RETURNING TO DEFAULT");
332 state default;
333 }
334 }
335
336 touch_start(integer total_number)
337 {
338 load_data();
339 if(MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
340 {
341 MY_STATE = 0;
342 save_data();
343 llSay(0,"Returning to unleased. Data might not be correct.");
344 state unleased;
345 }
346
347
348 llSay(0,"Space currently rented by " + LEASER);
349 llSay(0,"Rent due in " + timespan(llGetUnixTime()-LEASED_UNTIL));
350 }
351
352 }

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