Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

My rental space script (advanced)

Kick Madonna
Registered User
Join date: 19 Feb 2006
Posts: 16
04-03-2006 03:33
here it is. I was going to sale this, but i decided to ruin the market and release mime out for free. Have fun!!

You can reply to this thread for help. You need 3 images. One for the unleased state. One for unaviable/rent due, and one for the space being rented in the same object. Also a note card with more info on the space.

This leases by $L per day, it has a min and max peroid. It stores everything in the desc tag of the object so it can be reset and updated. It provides some other neat fatures. You can see it in action on my land (look for me in game and look at my picks for a tp).

Enjoy. (i give no warrenty. if it breaks and you loose all your $L, then too bad.)

CODE

list my_data;
integer MY_STATE =0;
string LEASER = "";
key LEASERID;
integer RATE =0;
integer PERIOD =0; //DAYS
integer PRIMMAX =0;
integer MAXPERIOD =0;
integer CHANNEL = 192;
integer CREDIT = 0;
integer LEASED_UNTIL = 0;
integer IS_RENEWABLE = FALSE;
integer can_renew = FALSE;
integer DAYSEC = 86400;
integer SENT_WARNING = FALSE;
integer RENTWARNING = 3; //Day allowed to renew earlier
integer GRACEPERIOD = 3; // Days allowed to miss payment
vector FULL_SIZE = <1.5,.375,1.5>;
vector SMALL_SIZE = <.25,.25,.25>;
integer INIT = FALSE;

DEBUG(string data)
{
llOwnerSay("DEBUG: " + data);
}

string get_rentalbox_info()
{
return llGetRegionName() + " @ " + (string)llGetPos() + " (Leaser: \"" + LEASER + "\", Expire: " + timespan(LEASED_UNTIL - llGetUnixTime()) + ")";
}

string timespan(integer time)
{

integer days = time / DAYSEC;
integer curtime = (time / DAYSEC) - (time % DAYSEC);
integer hours = curtime / 3600;
integer minutes = (curtime % 3600) / 60;
integer seconds = curtime % 60;

return (string)llAbs(days) + " days, " + (string)llAbs(hours) + " hours, "
+ (string)llAbs(minutes) + " minutes, " + (string)llAbs(seconds) + " seconds";

}

load_data()
{
integer len;
my_data = llCSV2List(llGetObjectDesc());
len = llGetListLength(my_data);
RATE = llList2Integer(my_data,0);
PERIOD = llList2Integer(my_data,1);
MAXPERIOD = llList2Integer(my_data,2);
PRIMMAX = llList2Integer(my_data,3);
IS_RENEWABLE = llList2Integer(my_data, 4);
MY_STATE = llList2Integer(my_data, 5);
LEASER = llList2String(my_data, 6);
LEASERID = llList2Key(my_data, 7);
CREDIT = llList2Integer(my_data, 8);
LEASED_UNTIL = llList2Integer(my_data, 9);
SENT_WARNING = llList2Integer(my_data, 10);
}

save_data()
{
my_data = [RATE,PERIOD, MAXPERIOD, PRIMMAX, IS_RENEWABLE, MY_STATE, LEASER, LEASERID, CREDIT, LEASED_UNTIL, SENT_WARNING];
llSetObjectDesc(llList2CSV(my_data));
}

default
{
state_entry()
{
if (!INIT)
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
INIT = TRUE;
}
load_data();
llSetScale(SMALL_SIZE);
llSetTexture("lease-ex",ALL_SIDES);
llOwnerSay("Click this rental box to activate after configuring.");
llSetText("DISABLED",<0,0,0>, 1.0);
}

on_rez(integer start_param)
{
load_data();
}

money(key giver, integer ammount)
{
llWhisper(0,"Unable to accept money right now");
llGiveMoney(giver,ammount);
}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner())
{
load_data();
if (PERIOD == 0 || RATE ==0 || (!IS_RENEWABLE && LEASED_UNTIL < llGetUnixTime()))
{
llSay(0,"This space is not currently purchasble or requires configuration.");
}
else
{
llSay(0,"Activating...");
if (MY_STATE == 0)
state unleased;
else if (MY_STATE == 1)
state leased;
}
}
}
}

state unleased
{
state_entry()
{
load_data();
if (MY_STATE !=0 || PERIOD == 0 || RATE == 0 || !IS_RENEWABLE)
{
llOwnerSay("Returning to default. Data might not be correct.");
state default;
}
llSetScale(FULL_SIZE);
//Blank texture
llSetTexture("5748decc-f629-461c-9a36-a35a221fe21f",ALL_SIDES);
llSetTexture("lease-large",1);
llSetTexture("lease-large",3);
llOwnerSay("Lease script is active...");
llSetText("",<1,0,0>, 1.0);

}

money(key giver, integer ammount)
{
load_data();
if (ammount < RATE * PERIOD)
{
llSay(0,"Sorry, you didn't pay anough.");
llGiveMoney(giver, ammount);
}
else if (ammount > MAXPERIOD * RATE)
{
llSay(0,"Sorry, you payed more then the max allows.");
llGiveMoney(giver, ammount);
}
else
{
llSay(0,"Thanks for renting! Please wait a few moments...");
MY_STATE = 1;
LEASER = llKey2Name(giver);
LEASERID = giver;
if ((ammount % RATE) != 0)
{
llSay(0,"oops, you overpaid. Here is a partial refund");
llGiveMoney(giver,(ammount % RATE));
}
CREDIT = (ammount - (ammount % RATE))/RATE;
LEASED_UNTIL = llGetUnixTime() + (CREDIT * DAYSEC);
SENT_WARNING = FALSE;
save_data();
llInstantMessage(llGetOwner(), "NEW LEASE - $" + (string)(ammount - (ammount % RATE)) + "L - " + get_rentalbox_info());
state leased;
}

}

touch_start(integer total_number)
{
load_data();
llSay(0,"Bay Hills Lease");
//llSay(0,"Only $L" + (string)RATE + " per day");
llSay(0, "Only $L" + (string)(RATE * PERIOD) + " for " + (string)PERIOD + " days ($L" + (string)RATE + " per day)");
llSay(0, "Initial Min. Lease Time: " + (string)PERIOD + " days");
llSay(0, "Max Lease Payment Length: " + (string)MAXPERIOD + " days");
llSay(0, "Max Prims: " + (string)PRIMMAX);
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD,0));
}
}

state leased
{
state_entry()
{
DEBUG("Leased mode");
DEBUG((string)llGetUnixTime());

load_data();
llSetScale(SMALL_SIZE);
llSetTexture("lease-question",ALL_SIDES);
llSetText("",<1,0,0>, 1.0);
if (MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
{
MY_STATE = 0;
save_data();
llOwnerSay("Returning to unleased. Data might not be correct.");
state unleased;
}
llSetTimerEvent(900); //15 minute checks

}

money(key giver, integer ammount)
{
load_data();
if (MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
{
MY_STATE = 0;
save_data();
llSay(0,"Returning to unleased. Data might not be correct.");
llGiveMoney(giver,ammount);
state unleased;
}

if (llGetOwner() != giver && giver != LEASERID)
{
llSay(0,"Well thats nice that you want to pay this rent but only the leaser may do so.");
llGiveMoney(giver,ammount);
}
else if (IS_RENEWABLE || llGetOwner() == giver)
{

integer timeleft = LEASED_UNTIL - llGetUnixTime();
integer curammount = (ammount - (ammount % RATE))/RATE; //Caculated sum after refund

if (((curammount * DAYSEC) + timeleft) > MAXPERIOD * DAYSEC)
{
llSay(0,"Sorry, you can not purchase more then the max time");
llGiveMoney(giver,ammount);
}
//**
//** - Not going to punish anyone right now after they sigh up. let them pay day by day
//**
//else if (((curammount * DAYSEC) + timeleft) < PERIOD * DAYSEC)
//{
// llSay(0,"You have to pay anough to meet the min time");
// llGiveMoney(giver,ammount);
//}
else
{

//Refund code
if ((ammount % RATE) != 0)
{
llSay(0,"oops, you overpaid. Here is a partial refund");
llGiveMoney(giver,(ammount % RATE));
}
CREDIT = curammount;
SENT_WARNING = FALSE;
LEASED_UNTIL += (curammount * DAYSEC);
save_data();
llSetScale(SMALL_SIZE);
llSetTexture("bayhill-question",ALL_SIDES);
llSetText("",<1,0,0>, 1.0);
llInstantMessage(llGetOwner(), "LEASE CREDIT - $" + (string) (curammount * RATE) + "L - " + get_rentalbox_info());
}
}
else
{
llGiveMoney(giver,ammount);
llSay(0,"Sorry you can not renew at this time.");
}

}

timer()
{
load_data();
if (MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
{
MY_STATE = 0;
save_data();
llSay(0,"Returning to unleased. Data might not be correct.");
state unleased;
}

if (IS_RENEWABLE)
{
if (LEASED_UNTIL > llGetUnixTime() && LEASED_UNTIL - llGetUnixTime() < RENTWARNING * DAYSEC)
{
llSetTexture("lease-ex",ALL_SIDES);
llSetText("Rent Due!",<1,0,0>, 1.0);
}
else if (LEASED_UNTIL < llGetUnixTime() && llGetUnixTime() - LEASED_UNTIL < GRACEPERIOD * DAYSEC)
{
if (!SENT_WARNING)
{
llInstantMessage(LEASERID, "Your rent is due! - " + get_rentalbox_info());
llInstantMessage(llGetOwner(), "RENT DUE - " + get_rentalbox_info());
SENT_WARNING = TRUE;
save_data();
}
llSetTexture("lease-ex",ALL_SIDES);
llSetText("RENT PAST DUE!",<1,0,0>, 1.0);
}
else if (LEASED_UNTIL < llGetUnixTime())
{
llInstantMessage(LEASERID, "Your lease has expired. Please clean up the space or contact the space owner.");
llInstantMessage(llGetOwner(), "LEASE EXPIRED: CLEANUP! - " + get_rentalbox_info());
MY_STATE = 0;
save_data();
state default;

}
}
else if (LEASED_UNTIL < llGetUnixTime())
{
llInstantMessage(llGetOwner(), "LEASE EXPIRED: CLEANUP! - " + get_rentalbox_info());
DEBUG("TIME EXPIRED. RETURNING TO DEFAULT");
state default;
}
}

touch_start(integer total_number)
{
load_data();
if (MY_STATE != 1 || PERIOD == 0 || RATE == 0 || LEASER == "" || CREDIT == 0)
{
MY_STATE = 0;
save_data();
llSay(0,"Returning to unleased. Data might not be correct.");
state unleased;
}


llSay(0,"Space currently rented by " + LEASER);
llSay(0,"Rent due in " + timespan(llGetUnixTime()-LEASED_UNTIL));
}

}
Sammi Moore
Registered User
Join date: 12 May 2006
Posts: 8
06-08-2006 02:54
I have tried and tried and tried but I can't get this script too work :(

Can any one help me with a 1 to 1 in SL of by sending me a compleated rental box with mod / copy ticked so I can see where im going wrong?

Thanks
jefferey Heart
Registered User
Join date: 25 Jan 2006
Posts: 45
06-08-2006 08:38
From: Sammi Moore
I have tried and tried and tried but I can't get this script too work :(

Can any one help me with a 1 to 1 in SL of by sending me a compleated rental box with mod / copy ticked so I can see where im going wrong?

Thanks


Contact Kick in world, he was very helpful in helping me get this script working... Gave me some good examples.
Danielle Vidor
Second Life liefhebber
Join date: 10 Jan 2007
Posts: 20
Advanced rental space script.
05-14-2007 13:31
Hi all,

I have been trying his script, just to find out how it works. But without a proper manual I got stuck.
Got a few questions:
- I can't find Kick in SL, is he no longer active?
- has anyone used this script, is it any good from the technical point of view? are there better examples to study on?
- can anyone spare me a few minutes in SL to explain how this stuff really works?

regards.
Danielle.
_____________________
The Av is not a look a Like!
Ephedra Loon
Registered User
Join date: 8 Jun 2007
Posts: 5
10-02-2007 13:04
I'm glad I'm not the only one who a) can't get the script to work and b) can't find Kick inworld.

Anyone willing to help me?
Danielle Vidor
Second Life liefhebber
Join date: 10 Jan 2007
Posts: 20
10-03-2007 13:39
From: Ephedra Loon
I'm glad I'm not the only one who a) can't get the script to work and b) can't find Kick inworld.

Anyone willing to help me?


I have figured it out with the help of a really nice guy (THNX Johnii)

The key to get it working was to put the correct parameters in the description line of the box.
Its in the thread: " It stores everything in the desc tag of the object so it can be reset and updated"

So: fill in the parameters like this 10,5,10,0,0,0, etc... in the Description tag of the box. When the script is started it reads these parameters.

Regards.
Danielle.
_____________________
The Av is not a look a Like!
Markus Brendel
Registered User
Join date: 16 Oct 2006
Posts: 13
10-31-2007 19:48
exactly how does the information get entered into the description line of the item, i have tried numerous attempts with no sucess.
Danielle Vidor
Second Life liefhebber
Join date: 10 Jan 2007
Posts: 20
11-01-2007 13:48
From: Markus Brendel
exactly how does the information get entered into the description line of the item, i have tried numerous attempts with no sucess.


When the edit window for the object is opened, there are 2 lines you fill in first: name and description. That is where this script reads the parameters.

This is very basic. You should be able to figure this out, but it is well hidden in the script. :)

Example:14, 7, 21, 1, 1, 0, , , , ,
14 lindens per day
7 day rental
21 day max
the rest are switches that need to be set
1 number of prims , is this renewable (needs to be 1).. or true)... ,
1 current state of rental = 0 for rentable... = 1 for rented
if i allowed 25 prims and it was currently renteed... it woudl be
35, 7, 21, 50, 1, 1, , , , ,

I think this should help you enough. Enjoy.

regards,
Danielle.
_____________________
The Av is not a look a Like!