by jakeman0074 » Sun Feb 21, 2010 8:04 pm
here is the script i need help with thanks.
- Code: Select all
string DEFAULT_TEXTURE = "cb8a501d-8d11-4f8c-96a5-382c1bd0c14b";
string RENTED_TEXTURE = "4f301545-847c-4afa-b406-e92f84b1c4c0";
string NEW_TENNANT_PG = "";
string NEW_TENNANT = "";
string EXPIRED = "";
string INFO = "";
key id;
list splitwith;
list splitname;
string ownername;
integer not_registered = TRUE;
vector original_location;
vector original_scale;
integer objects = 50; // objects
integer price = 100; // price
integer weeks = 1; // weeks
vector offset = <0, 0, 0>;
integer mature = 0;
string rentor;
string rentorkey;
integer rented = FALSE;
string rentperiod;
integer numListen;
integer randchannel;
integer editmode;
integer stopper;
string daterented;
integer rentedweeks;
integer timerevent;
integer menu_channel;
integer menu_handler;
menu(key user,string title,list buttons)//make dialog easy, pick a channel by itself and destroy it after 5 seconds
{
llListenRemove(menu_handler);
menu_channel = (integer)(llFrand(99999.0) * -1);//yup a different channel at each use
menu_handler = llListen(menu_channel,"",user,"");
llDialog(user,title,buttons,menu_channel);
}
RENTED()
{
if(rented)
{
integer weeks2 = timerevent / 7 / 24 / 60 / 60;
integer days = timerevent / 24 / 60 / 60 - (weeks2 * 7);
integer hours = timerevent / 60 / 60 - (weeks2 * 7 * 24) - (days * 24);
integer mins = timerevent / 60 - (weeks2 * 7 * 24 * 60) - (days * 24 * 60) - (hours * 60);
llSetText("Occupied by: " + rentor + "\n ___________\nTime Remaining\n" + (string)weeks2 + " weeks | " + (string)days + " days | " + (string)hours + " hours | " + (string)mins+" minutes",<1,1,1>,1);
}
else
{
integer monthprice=price*weeks;
llSetText(llGetObjectDesc()+"\n Available for rent\n \nm$"+(string)monthprice+" per "+(string)weeks +" week\n \n Prims:"+(string)objects,<1,1,1>,1);
}
}
default
{
on_rez(integer change)
{
llSetTexture(DEFAULT_TEXTURE, ALL_SIDES);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llListen(0,"","","");
editmode = 0;
timerevent = 0;
rented = FALSE;
RENTED();
}
listen(integer c, string n, key id, string m)
{
stopper = 0;
string objectname;
objectname = llGetObjectName();
if (m == "View ToS" && c == randchannel && rented == TRUE)
{
llGiveInventory(rentorkey,"Rentals Terms of Service");
}
if (m == "View Info" && c == randchannel && rented == TRUE)
{
llGiveInventory(rentorkey,"Rental Information");
}
if (m == "Vacate" && c == randchannel && id == llGetOwner() && rented == TRUE)
{
llSetTexture(DEFAULT_TEXTURE, ALL_SIDES);
llSetPos(original_location);
llSetScale(original_scale);
llListenRemove(numListen);
numListen = llListen(0, "", "", "" );
rentperiod = "";
rentor = "";
rentorkey = NULL_KEY;
rented = FALSE;
RENTED();
daterented = "";
rentedweeks = 0;
timerevent = 0;
llSetTimerEvent(0);
llSay(0, objectname + " is Vacant");
}
if (m == "Mature" && c == randchannel && id == llGetOwner())
{
mature = 1;
llSay(0,"set to Mature Area");
}
if (m == "Renter info" && c == randchannel && id == llGetOwner())
{
integer weeks2;
weeks2 = timerevent / 7 / 24 / 60 / 60;
integer days;
days = timerevent / 24 / 60 / 60 - (weeks2 * 7);
integer hours;
hours = timerevent / 60 / 60 - (weeks2 * 7 * 24) - (days * 24);
integer mins;
mins = timerevent / 60 - (weeks2 * 7 * 24 * 60) - (days * 24 * 60) - (hours * 60);
integer seconds;
seconds = timerevent - (weeks2 * 7 * 24 * 60 * 60) - (days * 24 * 60 * 60) - (hours * 60 * 60) - (mins * 60);
llOwnerSay("Renter name: " + rentor);
llOwnerSay("Rented Date: " + daterented);
llOwnerSay("Rented Left: " + (string)weeks2 + " weeks | " + (string)days + " days | " + (string)hours + ":" + (string)mins + ";" +(string)seconds);
if (rentedweeks >= 2)
{
llOwnerSay("Rented amount: " + (string)rentedweeks + " weeks");
}
if (rentedweeks == 1)
{
llOwnerSay("Rented amount: " + (string)rentedweeks + " week");
}
if (rentedweeks <= 0)
{
llOwnerSay("Rented amount: N/A");
}
}
if (m == "PG" && c == randchannel && id == llGetOwner())
{
mature = 0;
llSay(0,"set to PG Area");
}
if (m == "Status" && c == randchannel && id == llGetOwner())
{
string mit;
llOwnerSay("Prim's set to " + (string)objects);
llOwnerSay("Week's set to " + (string)weeks);
llOwnerSay("Offset set to " + (string)offset);
if (mature == 1)
{
mit = "Yes";
}
else
{
mit = "No";
}
llOwnerSay("Region Mature: " + (string)mit);
}
if(m == "Edit Mode" && editmode == 0 && stopper == 0 && c == randchannel && id == llGetOwner())
{
stopper = 1;
editmode = 1;
llOwnerSay("editmode on");
}
if(m == "Edit Mode" && editmode == 1 && stopper == 0 && c == randchannel && id == llGetOwner())
{
stopper = 1;
editmode = 0;
llOwnerSay("editmode off");
}
if (m == "Help" && c == randchannel && llGetOwner() == id )
{
llGiveInventory(llGetOwner(), "Rentals Help");
}
if (llGetSubString(m,0,8) == "set weeks" && id==llGetOwner() && editmode == 1)
{
weeks = (integer)llGetSubString(m,9,llStringLength(m));
llSay(0,"weeks set to " + (string)weeks);
}
if (llGetSubString(m,0,10) == "set renter " && id==llGetOwner() && editmode == 1)
{
rentor = llGetSubString(m,11,llStringLength(m));
llSay(0,"renter set to " + rentor);
}
if (llGetSubString(m,0,9) == "set split " && id==llGetOwner() && editmode == 1)
{
key SPLIT = (key)llGetSubString(m,10,llStringLength(m));
splitwith += SPLIT;
splitname += llKey2Name(SPLIT);
llSay(0,llKey2Name(SPLIT) + " added to split with list");
}
if (llGetSubString(m,0,12) == "split remove " && id==llGetOwner() && editmode == 1)
{
string name = llGetSubString(m,13,llStringLength(m));
integer finddata = llListFindList(splitname,(list)name);
if(finddata == -1)
{
llSay(0,"sorry " + name + " not found");
}else
{
llDeleteSubList(splitwith,finddata,finddata);
llDeleteSubList(splitname,finddata,finddata);
llSay(0,name +" removed from shared list");
}
}
if (llGetSubString(m,0,13) == "set rentedfor " && id==llGetOwner() && editmode == 1)
{
string date = llGetTimestamp();
daterented = llGetSubString(date,8,9) + "/" + llGetSubString(date,5,6) + "/" + llGetSubString(date,0,3) + " | Time " + llGetSubString(date,11,15);
if(!rented)
{
original_scale = llGetScale();
original_location = llGetPos();
}
list renttime = llParseStringKeepNulls(llGetSubString(m,14,llStringLength(m)), [":"], []);
integer days = llList2Integer(renttime,0);
integer hours = llList2Integer(renttime,1);
integer minites = llList2Integer(renttime,2);
integer seconds = llList2Integer(renttime,3);
integer total;
total = (days * 24 * 60 * 60) + (hours * 60 * 60) + (minites * 60) + (seconds);
llSetTexture(RENTED_TEXTURE, ALL_SIDES);
llSetPos(original_location + offset);
llSetScale(<0.236,0.236,0.236>);
timerevent = total;
llSetTimerEvent(60);
llWhisper(0,"set to " + (string)days + " days " + (string)hours + " hours " + (string)minites + " mins " + (string)seconds + " seconds");
rented = TRUE;
}
if (llGetSubString(m,0,10) == "set offset " && id==llGetOwner() && editmode == 1)
{
offset = (vector)llGetSubString(m,11,llStringLength(m));
llSay(0,"Offset set to " + (string)offset);
}
if (llGetSubString(m,0,8) == "set prims" && id==llGetOwner() && editmode == 1)
{
objects = (integer)llGetSubString(m,9,llStringLength(m));
llSay(0,"Prims set to " + (string)objects);
}
if (llGetSubString(m,0,8) == "set price" && id==llGetOwner() && editmode == 1)
{
price = (integer)llGetSubString(m,9,llStringLength(m));
llSay(0,"Price set to m$" + (string)price);
}
if(id==llGetOwner() ||id==rentorkey)
{
RENTED();
}
llSetPayPrice(PAY_HIDE, [price,price*2,price*3,price*4]);
}
state_entry()
{
editmode = 0;
randchannel = (integer)llFrand(10000000);
llWhisper(0, "Activating...");
ownername = llKey2Name(llGetOwner());
llWhisper(0, "Asking for permission from owner " + ownername + ".");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
original_location = llGetPos();
original_scale = llGetScale();
llListenRemove(numListen);
rentedweeks = 0;
numListen = llListen(0, "", "", "" );
llListen(randchannel,"","","");
timerevent = 0;
llSetTexture(DEFAULT_TEXTURE, ALL_SIDES);
}
run_time_permissions(integer type)
{
if (type == PERMISSION_DEBIT)
{
ownername = llKey2Name(llGetOwner());
llSetPayPrice(PAY_HIDE, [price,price*2,price*3,price*4]);
llWhisper(0, "This space is now available for rent.");
integer monthprice=price*weeks;
llSetText(llGetObjectDesc()+"\n Available for rent\n \nm$"+(string)monthprice+" per "+(string)weeks +" week\n \n Prims:"+(string)objects,<1,1,1>,1);
not_registered = FALSE;
}
}
timer() {
llListenRemove(menu_handler);
timerevent = timerevent - 60;
if (timerevent > 0)
{
RENTED();
}
else
{
if(rentorkey != NULL_KEY)
{
llInstantMessage(rentorkey,"Your rental at " + llGetRegionName() + " has expired");
}
llSay(0,"rental expired");
string objectname;
objectname = llGetObjectName();
llSetTexture(DEFAULT_TEXTURE, ALL_SIDES);
llSetPos(original_location);
llSetScale(original_scale);
numListen = llListen(0, "", "", "" );
rentperiod = "";
rentor = "";
rentorkey = NULL_KEY;
daterented = "";
rentedweeks = 0;
rented = FALSE;
timerevent = 0;
llSetTimerEvent(0);
RENTED();
}
}
touch_start(integer total_number)
{
if(llDetectedKey(0) == rentorkey)
{
llDialog(rentorkey,"User's Menu\n_______________\n VIEW ToS= View the Terms of Service\nVIEW INFO= View the rentals info",["View ToS","View Info"],randchannel);
}
if(llDetectedKey(0) == llGetOwner())
{
string edit;
if (editmode == 0)
{
edit = "off";
}
if (editmode == 1)
{
edit = "on";
}
llDialog(llGetOwner(),"Rentals editor \n editmode is set to: " + edit,["Mature","PG","Vacate","Edit Mode","Renter info","Help","Status"],randchannel);
}
else
{
if(rented == FALSE)
{
llWhisper(0, "This space is for rent. The price is $" +(string)price+ " per week. Prim limit is "+(string)objects+" prims. Please observe the Terms of Service to avoid termination of agreement. Rent is refundable at our discretion.");
llGiveInventory(llDetectedKey(0),"Rental Terms of Service");
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 or need help, please feel free to IM " + ownername + ".");
}
else
{
llWhisper(0, "This space is occupied by " + rentor);
}
}
}
money(key giver, integer amount)
{
integer amount2 = amount%price;
integer weeks = amount/price;
if(amount>=price*weeks && amount2==0 && rented == FALSE)
{
rentedweeks = amount/price;
string date = llGetTimestamp();
daterented = llGetSubString(date,8,9) + "/" + llGetSubString(date,5,6) + "/" + llGetSubString(date,0,3) + " | Time " + llGetSubString(date,11,15);
original_scale = llGetScale();
original_location = llGetPos();
timerevent = 604800*weeks;
rentor = llKey2Name(giver);
rented = TRUE;
RENTED();
rentperiod = (string)weeks;
llWhisper(0, "Thank you for your custom! You have paid for "+(string)weeks+" weeks rental of "+llGetObjectDesc()+". Feel free to put your stuff in now!");
llSetTexture(RENTED_TEXTURE, ALL_SIDES);
llSetPos(original_location + offset);
llSetScale(<0.236,0.236,0.236>);
rentorkey = giver;
llGiveInventory(rentorkey,"Rental Information");
llGiveInventory(rentorkey,"Rental Terms of Service");
llSetTimerEvent(60);
if(splitwith ==[])
{
llInstantMessage(llGetOwner(),rentor +" paid m$"+ (string)amount +" for "+(string)weeks +" weeks rental of "+llGetObjectDesc());
}
else if (splitwith != [])
{
integer devide = llGetListLength(splitwith) + 1;
integer totatogive = amount/devide;
integer no;
while(no < llGetListLength(splitwith))
{
key dest = llList2Key(splitwith,no);
llGiveMoney(dest,totatogive);
llInstantMessage(dest,"you have been paid m$"+ (string)totatogive +" by " + llGetObjectName());
no ++;
}
}
}
else if(rented == TRUE)
{
if (llKey2Name(giver) == rentor && amount>=price*weeks && amount2==0)
{
timerevent += (604800*weeks);
llSay(0, "you have increased your rental by " + (string)weeks + " weeks");
rentedweeks += weeks;
if(splitwith != [])
{
integer devide = llGetListLength(splitwith) + 1;
integer totatogive = amount/devide;
integer no;
while(no < llGetListLength(splitwith))
{
key dest = llList2Key(splitwith,no);
llGiveMoney(dest,totatogive);
llInstantMessage(dest,"you have been paid m$"+ (string)totatogive +" by " + llGetObjectName());
no ++;
}
}
}
else
{
llGiveMoney(giver, amount);
llSay(0,"Please check Rental! Giving money back.");
}
}
else
{
llWhisper(0, "Minimum rental period is "+(string)weeks+" weeks, at m$" +(string)(price*weeks)+ ". If you have any questions, please feel free to IM" + ownername + ".");
llWhisper(0, "Giving money back.");
llGiveMoney(giver, amount);
}
}
}
"Your true traveler finds boredom rather agreeable than painful. It is the symbol of his liberty - his excessive freedom. He accepts his boredom, when it comes, not merely philosophically, but almost with pleasure.”