는 공간을 임대 .lsl 작성 아래 스크립트에 문제 하나의 임차인의 A (첫번째 임차인을) 할 수 있도록 설계되어문제 (린든 스크립팅 언어)
(린든 스크립팅 언어)가 임차인을위한 공간을 임대 할 수 있습니다.
첫 번째 문제점은 임차인 B가 공간을 빨리 임대 할 시간입니다. 상태 활성에서 적용
두 번째 문제는 임차인 B가 임차인 A가 처음 설정 한 총 임차인의 최소 25 %를 지불해야한다는 것이지만 임금 격납고를 지불 한 후에 임차인 B는 지불 된 총 금액조차 더 이상 지불 할 수 없습니다 임차인 A가 정하는 항목이어야합니다.
//varibles for renter A
// elapsedRentalTime = .0;
// rentalTime = 0;
// rentalName = "<No body>";
// rentalUUID = NULL_KEY;
// rentalSetPrice = 0;
// rentalSetTime = .0;
//varibles for renter B
// endName = "<No Body>";
// endUUID = NULL_KEY;
// endRentalTime = .0;
// endRentalPayd = 0;
희망 사항은이 문제에 도움이 될 수 있습니다. 또한 죄송 어떤 typeos을 위해있을 수 있습니다)
//cant pay after the int 25% of amt/renter time for renter B ends to fast
integer chan;
list butPrice = ["0","1","2","3","4","5","6","7","8","9","Set price","Reset price"];
list butTime = ["Hour+","Hour-","Day+","Day-","Week+","Week-","Set time","Reset time"];
integer lis1;
key owner;
integer rentPrice;
float rentTime;
float dialogTime = .0;
key rentalUUID = NULL_KEY;
string rentalName = "<No body>";
float rentalTime;
float elapsedRentalTime;
integer rentalSetPrice;
float rentalSetTime;
key endUUID = NULL_KEY;
string endName = "<No body>";
float endRentalTime;
integer endRentalPayd;
float ONE_WEEK = 604800.0;
float ONE_DAY = 86400.0;
float ONE_HOUR = 3600.0;
string getTimeString(integer time){
string str;
integer week;
integer days;
integer hours;
integer minutes;
integer seconds;
week = llRound(time/604800);
time = time % 604800;
days = (time/86400);
time = time % 86400;
hours = (time/3600);
time = time % 3600;
minutes = time/60;
time = time % 60;
seconds = time;
if(week)
str += (string)week + " weeks, ";
if(days)
str += (string)days + " days, ";
if(hours)
str += (string)hours + " hours, ";
if(minutes)
str += (string)minutes + " minutes, ";
if(seconds)
str += (string)seconds + " seconds, ";
if(str != "")
str = llDeleteSubString(str,-2,-1);
if(str == "")
str = "Not Set!";
return str;
}
Dialog2(key i,string str,list but){
dialogTime += 15.;
llListenRemove(lis1);
lis1 = llListen(chan,"","","");
llDialog(i,str,but,chan);
}
EndRental(){
llSetTimerEvent(.0);
elapsedRentalTime = .0;
rentalTime = 0;
rentalName = "<No body>";
rentalUUID = NULL_KEY;
rentalSetPrice = 0;
rentalSetTime = .0;
endName = "<No Body>";
endUUID = NULL_KEY;
endRentalTime = .0;
endRentalPayd = 0;
llMessageLinked(LINK_THIS, 1, "Free space|Rate L$"+(string)rentPrice+" \ week|Max: "+getTimeString((integer)rentTime), llGetKey());
}
integer subPrice;
integer Config1(key i,string m){
if(m == "Set price"){
Dialog2(i,"Price: "+(string)subPrice+"L$",["Ok"]);
return subPrice;
}
else if(m == "Reset price")
subPrice = 0;
else
subPrice = (integer)((string)subPrice+m);
Dialog2(i,"(Set price)\n"+(string)subPrice+"L$",butPrice);
return subPrice;
}
integer subTime;
integer Config2(key i,string m){
if(m == "Hour+")
subTime += 3600;
else if(m == "Hour-")
subTime -= 3600;
else if(m == "Day+")
subTime += 86400;
else if(m == "Day-")
subTime -= 86400;
else if(m == "Week+")
subTime += 604800;
else if(m == "Week-")
subTime -= 604800;
else if(m == "Set time"){
Dialog2(i,"Time: "+(string)getTimeString(subTime),["Ok"]);
return subTime;
}
else if(m == "Reset time")
subTime = 0;
Dialog2(i,"(Set time)\n"+getTimeString((integer)subTime),butTime);
return subTime;
}
TextInfo(){
llWhisper(0,"Price: L$ "+(string)rentPrice+"/week\nMax time: "+getTimeString((integer)rentTime)+"\n---------------------\nRenter: "+rentalName+"\nEnd user: "+endName+
"\n---------------------\nPrice: L$ "+(string)rentalSetPrice+"\nTime: "+getTimeString((integer)rentalSetTime));
}
DisplayInfo(){
llMessageLinked(LINK_THIS, 1, "COST: "+(string)rentalSetPrice+"|PAID: "+(string)endRentalPayd+"|BUYER: "+endName, llGetKey());
}
default{
touch_end(integer e){
if(llDetectedKey(0) == owner){
subTime = subPrice = 0;
if(dialogTime == .0)
llSetTimerEvent(5.);
Dialog2(owner,"(Menu)",["Price","Time","Info","Activet"]);
}
}
listen(integer c,string n,key i,string m){
if(i == owner){
if(m == "Info")
TextInfo();
else if(m == "Activet"){
llMessageLinked(LINK_THIS, 1, "Free space|Rate L$"+(string)rentPrice+" \ week|Max: "+getTimeString((integer)rentTime), llGetKey());
llSetTimerEvent(.0);
state active;
}
else if(~llListFindList(butPrice,[m]) || m == "Price")
rentPrice = Config1(i,m);
else if(~llListFindList(butTime,[m]) || m == "Time")
rentTime = (float)Config2(i,m);
}
}
timer(){
float elapsedTime = llGetTime();
llResetTime();
if((dialogTime -= elapsedTime) <= .0){
dialogTime = .0;
llListenRemove(lis1);
llSetTimerEvent(.0);
}
}
run_time_permissions(integer p){
if(!(p & PERMISSION_DEBIT)){
llOwnerSay("Debit perm not set! Reseting script...");
llResetScript();
}
}
state_entry(){
owner = llGetOwner();
llRequestPermissions(owner,PERMISSION_DEBIT);
chan = (integer)llGetSubString("0x"+(string)llGetKey(),-1,-5);
}
on_rez(integer r){
llResetScript();
}
}
state active{
state_entry(){
}
touch_end(integer e){
key id = llDetectedKey(0);
if(id == rentalUUID){
Dialog2(rentalUUID,"(Renter Menu)",["Price","Time","End rental","Info"]);
}
else if(id == owner)
Dialog2(owner,"(Owner menu)",["No refund","Refund","Info"]);
else
Dialog2(id,"(Menu)",["Info"]);
}
listen(integer c,string n,key i,string m){
if(m == "Info")
TextInfo();
else if(i == rentalUUID){
if(m == "End rental")
Dialog2(rentalUUID,"(Menu)\nEnd rental with no refun?",["No ref!","Cancel"]);
else if(m == "No ref!")
EndRental();
else if(~llListFindList(butPrice,[m]) || m == "Price")
rentalSetPrice = Config1(i,m);
else if(~llListFindList(butTime,[m]) || m == "Time")
rentalSetTime = (float)Config2(i,m);
if(rentalSetTime+elapsedRentalTime > rentTime+120.){
rentalSetTime = 0;
llInstantMessage(rentalUUID,"Time set is greater then max rental time allowd");
}
DisplayInfo();
}
else if(i == owner){
if(m == "No refund")
Dialog2(owner,"(Owner menu)\nEnd rental with no refund?",["No ref!","Cancel"]);
else if(m == "Refund")
Dialog2(owner,"(Owner menu)\nEnd rental with refund?",["Ref!","Cancel"]);
else if(m == "No ref!")
EndRental();
else if(m == "Ref!"){
integer amt = (integer)(rentalTime * rentPrice/ONE_WEEK);
if(amt)
llGiveMoney(rentalUUID,amt);
EndRental();
}
}
}
timer(){
float elapsedTime = llGetTime();
llResetTime();
rentalTime -= elapsedTime;
elapsedRentalTime += elapsedTime;
endRentalTime -= elapsedTime;
dialogTime -= elapsedTime;
if(rentalTime <= .0 && rentalUUID != NULL_KEY){
llInstantMessage(rentalUUID,"Your rental time at "+llGetRegionName()+" has now ended.");
EndRental();
}
if(endRentalTime <= .0 && endUUID != NULL_KEY){
llInstantMessage(endUUID,"Your rental time at "+llGetRegionName()+" has now ended.");
endName = "<No Body>";
endUUID = NULL_KEY;
endRentalTime = .0;
endRentalPayd = 0;
DisplayInfo();
}
if(dialogTime <= .0){
dialogTime = .0;
llListenRemove(lis1);
}
}
money(key i,integer amt){
float sum;
sum = ONE_WEEK * amt/rentPrice;
if(i == rentalUUID && sum + rentalTime + elapsedRentalTime <= rentTime){
rentalTime += sum;
llInstantMessage(rentalUUID,"You have refiled for "+getTimeString((integer)sum)+"\nand your total time is "+getTimeString((integer)sum));
}
else if(rentalUUID == NULL_KEY && sum <= rentTime){
rentalUUID = i;
rentalName = llKey2Name(rentalUUID);
rentalTime = sum;
llResetTime();
llInstantMessage(rentalUUID,"Your time left is "+getTimeString((integer)sum));
llSetTimerEvent(30.);
}
else if(i == endUUID && endRentalPayd+amt <= rentalSetPrice){
endRentalTime += rentalSetTime * amt/rentalSetPrice;
endRentalPayd += amt;
llGiveMoney(rentalUUID,amt);
llInstantMessage(endUUID,"Your time left is "+getTimeString((integer)endRentalTime));
}
else if(endUUID == NULL_KEY && amt >= rentalSetPrice*25/100 && amt <= rentalSetPrice && rentalUUID != NULL_KEY){
endUUID = i;
endName = llKey2Name(endUUID);
endRentalTime = rentalSetTime * amt/rentalSetPrice;
endRentalPayd = amt;
llGiveMoney(rentalUUID,amt);
llInstantMessage(endUUID,"Your time left is "+getTimeString((integer)endRentalTime));
}
else
llGiveMoney(i,amt);
DisplayInfo();
}
}