02-18-2013, 02:04 AM
PHP Code:
//////////////// EDIT THIS PART //////////////////////////////
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
integer price=50;//Price per week.
integer weeks=4;//Maximum number of weeks to be paid.
key rent_texture="000000-0000-0000-0000-000000000000";//Rightclick the texture in your inventory and click Copy UUID, then paste it inhere.
string rent_notecard="auto";// put the notecard name or keep it on auto, to detect the name automaticly.
integer notify_days=3;//Notification before renting time is over,(notifying once a day)
string touch_message="Is recieving your Advertisement. (click on your advertisement to disable)";//Touched avatar name + this message will be send to the tenant if touch notification enabled.
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
//////////////// END //////////////////////////////
//////////////// ONLY EDIT IF YOUR KNOW WHAT YOUR DOING //////////////////////////////
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
integer activated_time;
integer counted_time;
integer begin_time;
integer check;
string texture="";
string notecard;
string landmark;
string object;
integer notify=TRUE;
string noti="INFO Off";
integer paid;
integer total_clicks=0;
key tenant;
key owner;
integer active=FALSE;
integer chan=-9089879;
integer lag;
integer anti_spam;
set_texture(string text){
llSetTexture(text,2);
llSetTexture(text,4);
}
delete(){llAllowInventoryDrop(FALSE);
object="";
texture="";
notecard="";
landmark="";
integer i;string cur;
for(i=-1;llGetInventoryNumber(INVENTORY_ALL)-1>=i;++i){
cur=llGetInventoryName(INVENTORY_ALL,i);
if(cur!=llGetScriptName()&&cur!=rent_notecard){
if(llGetInventoryName(INVENTORY_ALL,i)!="") {
llWhisper(0,"/me :: "+(string)llGetInventoryName(INVENTORY_ALL,i)+" Deleted.");
llRemoveInventory(llGetInventoryName(INVENTORY_ALL,i));i-=1;}}
}}
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{owner=llGetOwner(); llAllowInventoryDrop(FALSE);
string snam=llGetScriptName();
if(llGetInventoryName(INVENTORY_NOTECARD,0)=="")llOwnerSay("/me :: Missing Instructions notecard.");
if(rent_notecard=="auto")rent_notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
set_texture(rent_texture);
llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
if(llGetSubString(snam,0,3)!="[KK]")llSetScriptState(snam,0);
}
touch_start(integer total_number)
{
if(llDetectedKey(0)==owner)llRequestPermissions(owner, PERMISSION_DEBIT);
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_DEBIT)
state cash;
}
}
state cash
{ on_rez(integer start_param)
{
llResetScript();;
}
state_entry()
{ llOwnerSay("/me :: Renting Enabled...");
string snam=llGetScriptName();
llSetPayPrice(PAY_HIDE, [price, (price*2), (price*3), (price*4)]);
llAllowInventoryDrop(FALSE);
if(llGetSubString(snam,0,3)!="[KK]")llSetScriptState(snam,0);
if(llGetSubString(snam,37,37)!="s")llSetScriptState(snam,0);
if(rent_notecard=="auto"||rent_notecard=="")rent_notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
}
touch_start(integer total_number)
{
key touched=llDetectedKey(0);
if(touched!=tenant){
if(active){
if(touched==owner){
counted_time=llGetUnixTime()-begin_time;
counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
llOwnerSay("/me : This tenant has "+(string) days+" day(s) remaining. And has been renting for: "+(string)((llGetUnixTime()-begin_time)/86400 )+" day(s). CTRL+H: secondlife:///app/agent/"+(string)tenant+"/about");
llListenRemove(lag); lag=llListen(chan, "", owner, "");
llDialog(owner, "Owner Options" ,["+1 Week","-1 Week","Who?","+1 Day","-1 Day","Evict","Content"], chan);
}else{
total_clicks+=1;
if(notecard!="")llGiveInventory(llDetectedKey(0) ,notecard);
if(landmark!="")llGiveInventory(llDetectedKey(0) ,landmark);
if(object!="")llGiveInventory(llDetectedKey(0) ,object);
if(notify){
if(llGetUnixTime()-anti_spam>=10){anti_spam=llGetUnixTime();
string ob=llGetObjectName();
llSetObjectName(llKey2Name(touched));
llInstantMessage(tenant,"/me "+touch_message);
llSleep(.1);
llSetObjectName(ob);
}
}
}
}else{
llDialog(touched, "
Advertisement Cost: "+(string)price+"L$ Per week." ,["Ok"], -792735);
if(rent_notecard!="auto"&&rent_notecard!="") llGiveInventory(touched ,rent_notecard);
}}else if(touched==tenant){
if(check==1){llWhisper(0,"/me :: Loading Invetory...");
return;}
llListenRemove(lag); lag=llListen(chan, "", tenant, "");
llDialog(tenant, "Content Menu
Click Reset to add new content" ,["Ready","Test Give","Reset","Leave","Total Cl."]+noti, chan);
}
}
listen(integer chan, string name, key id, string mes)
{
llListenRemove(lag);
if(id==owner){
if(mes=="+1 Week"){
activated_time+=86400 *7;
counted_time=llGetUnixTime()-begin_time;counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
llOwnerSay("/me :: Added 1 Week. "+(string)days+" Days left.");}
else if(mes== "Content"){total_clicks+=1;
if(notecard!="")llGiveInventory(llDetectedKey(0) ,notecard);
if(landmark!="")llGiveInventory(llDetectedKey(0) ,landmark);
if(object!="")llGiveInventory(llDetectedKey(0) ,object);}
else if(mes=="-1 Week"){
activated_time-=86400 *7;
counted_time=llGetUnixTime()-begin_time;counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
llOwnerSay("/me :: Deleted 1 Week. "+(string)days+" Days left.");}
else if(mes=="+1 Day"){
activated_time+=86400 ;
counted_time=llGetUnixTime()-begin_time;counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
llOwnerSay("/me :: Added 1 Day. "+(string)days+" Days left.");}
else if(mes=="-1 Day"){
activated_time-=86400 ;
counted_time=llGetUnixTime()-begin_time;counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
llOwnerSay("/me :: Deleted 1 Day. "+(string)days+" Days left.");}
else if(mes=="Who?"){
llOwnerSay("/me :: Press CTRL+H: secondlife:///app/agent/"+(string)tenant+"/about");
}
else if(mes=="Evict"){
lag=llListen(chan, "", owner, "");
llDialog(owner, "
Refund Yes? or No?" ,["Yes","No"], chan);
}
else if(mes=="No"||mes=="Yes"){
total_clicks=0;check=0;
if(mes=="Yes"){
activated_time/=86400;
activated_time/=7;
llGiveMoney(tenant, activated_time*price);
llInstantMessage(tenant,"Your advertisment has been terminated by the Owner.(Your rent has been refunded) CTRL+H: secondlife:///app/agent/"+(string)owner+"/about");}
else if(mes=="No"){
llInstantMessage(tenant,"Your advertisment has been terminated by the Owner.(Without refunds) CTRL+H: secondlife:///app/agent/"+(string)owner+"/about");
}
active=FALSE;paid=0;activated_time=0;
vector pos=llGetPos();
tenant=NULL_KEY;set_texture(rent_texture);delete();
}
}
if(mes=="Ready"){llAllowInventoryDrop(FALSE);check=0;
if(texture!="")set_texture(texture);
llWhisper(0,"/me ::: Advertisement running... With "+(string)(activated_time/86400 )+" Days Remaining Renting Time.");}
else if(mes=="INFO Off"){noti="INFO On";notify=FALSE; llWhisper(0,"/me :: Touch notifications disabled.");}
else if(mes=="INFO On"){noti="INFO Off";notify=TRUE; llWhisper(0,"/me :: Touch notifications enabled.");}
else if(mes=="Total Cl."){llWhisper(0,"/me :: Has been "+(string)total_clicks+" times touched.");
counted_time=llGetUnixTime()-begin_time;
counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
integer hours = llFloor((counted_time / 3600) - (days * 24));
integer minutes = llFloor((counted_time / 60) - (days * 1440) - (hours * 60));
llWhisper(0,"/me :: "+(string)days+" day(s) "+(string)hours+" hour(s) and "+(string)minutes+" minute(s). Remaining Renting Time."); }
else if(mes=="Reset"){
set_texture(rent_texture); delete();
llWhisper(0,"/me :: Content deleted, drop your landmark, texture and or notecard in.");llAllowInventoryDrop(TRUE);}
else if(mes=="Leave"){active=FALSE;llWhisper(0,"/me :: Advertisement ended, there will be no refunds.");tenant=NULL_KEY;set_texture(rent_texture);
paid=0;activated_time=0;total_clicks=0;check=0;
delete();
}
else if(mes=="Test Give"){if(notecard!="")llGiveInventory(id ,notecard);
if(landmark!="")llGiveInventory(id ,landmark);
if(object!="")llGiveInventory(id ,object);
if(notify){
string ob=llGetObjectName();
llSetObjectName(llKey2Name(id));
llInstantMessage(owner,"/me "+touch_message);
llSleep(.1);
llSetObjectName(ob);
}
}
}
timer(){ llSetTimerEvent(0); if(check==1||check==3){check=2;
if(llGetInventoryNumber(INVENTORY_TEXTURE)!=0&&texture==""){texture=llGetInventoryName(INVENTORY_TEXTURE,0);llWhisper(0,"/me :: Recieved texture: "+texture);
set_texture(texture);}
if(llGetInventoryNumber(INVENTORY_NOTECARD)>1&¬ecard==""){
if(llGetInventoryName(INVENTORY_NOTECARD,0)==rent_notecard)
notecard=llGetInventoryName(INVENTORY_NOTECARD,1);
else notecard=llGetInventoryName(INVENTORY_NOTECARD,0);
integer per=llGetInventoryPermMask(notecard, MASK_NEXT);
if ((per & PERM_TRANSFER)&&(per & PERM_COPY)) { llWhisper(0,"/me :: Recieved notecard: "+notecard);}else{llWhisper(0, "/me :: Warning! No copy and/or transfer permissions on: "+notecard+" add a new one with copy and transfer enabled.");
llRemoveInventory(notecard);notecard="";}
}
if(llGetInventoryNumber(INVENTORY_LANDMARK)!=0&&landmark==""){
landmark=llGetInventoryName(INVENTORY_LANDMARK,0);
integer per=llGetInventoryPermMask(landmark, MASK_NEXT);
if ((per & PERM_TRANSFER)&&(per & PERM_COPY)) { llWhisper(0,"/me :: Recieved landmark: "+landmark);}else{llWhisper(0, "/me :: Warning! No copy and/or transfer permissions on: "+landmark+" add a new one with copy and transfer enabled.");
llRemoveInventory(landmark);landmark="";}
}
if(llGetInventoryNumber(INVENTORY_OBJECT)!=0&&object==""){object=llGetInventoryName(INVENTORY_OBJECT,0);
integer per=llGetInventoryPermMask(object, MASK_NEXT);
if ((per & PERM_TRANSFER)&&(per & PERM_COPY)) { llWhisper(0,"/me :: Recieved object: "+object);}else{llWhisper(0, "/me :: Warning! No copy and/or transfer permissions on: "+object+" add a new one with copy and transfer enabled.");
llRemoveInventory(object);object="";}
}
llSetTimerEvent(10);
}
else if(check==2){check=3; llSetTimerEvent(10);
if(tenant!=NULL_KEY) llInstantMessage(tenant,"/me : Touch the board and select Ready in menu, to start the advertising.");
}
if(active&&check==0){
counted_time=llGetUnixTime()-begin_time;
counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
if(days<=notify_days){
if(days>0){ vector pos=llGetPos();
integer hours = llFloor((counted_time / 3600) - (days * 24));
integer minutes = llFloor((counted_time / 60) - (days * 1440) - (hours * 60));
llInstantMessage(tenant," Your advertisment time at "+llGetRegionName()+" will run out in "+(string)days+" day(s) "+(string)hours+" hour(s) and "+(string)minutes+" minute(s). (CTRL+P: secondlife:///app/teleport/"+llGetRegionName()+"/"+(string)pos.x+"/"+(string)pos.y+"/"+(string)pos.z+" )");
}
else{active=FALSE;paid=0;activated_time=0;check=0;
vector pos=llGetPos();total_clicks=0;
llInstantMessage(tenant," Your advertisment rent time at "+llGetRegionName()+" has ended. (CTRL+P: secondlife:///app/teleport/"+llGetRegionName()+"/"+(string)pos.x+"/"+(string)pos.y+"/"+(string)pos.z+" )");tenant=NULL_KEY;set_texture(rent_texture);delete();}
}
llSetTimerEvent(86400);}
}
money(key id, integer amount)
{
if(paid+amount > (price*weeks)||amount<price||(active&&id!=tenant))
{
llGiveMoney(id, amount);
if(active&&id!=tenant){ llInstantMessage(id, "Is allready rented by someone else: "+(string)amount+"L$ has been returned.");}
else if (paid+amount > (price*weeks))
llInstantMessage(id, "Maximum rent weeks are purchased: "+(string)amount+"L$ has been returned.");
else if (amount<price){llInstantMessage(id, "Insufficient money paid: "+(string)amount+"L$ has been returned.");
} }
else
{
if(!active){begin_time=llGetUnixTime();}
paid+=amount;
string snam=llGetScriptName();
integer count=amount/price;
count*=7;//7
//86400
activated_time+=86400 *count;
counted_time=llGetUnixTime()-begin_time;
counted_time=activated_time-counted_time;
integer days=86400;
days=(llFloor(counted_time/days));
if(llGetSubString(snam,37,37)!="s")llSetScriptState(snam,0);
integer hours = llFloor((counted_time / 3600) - (days * 24));
integer minutes = llFloor((counted_time / 60) - (days * 1440) - (hours * 60));
llWhisper(0,"/me :: "+(string)days+" day(s) "+(string)hours+" hour(s) and "+(string)minutes+" minute(s). Remaining Renting Time.");
llSetTimerEvent(1);
if(!active){tenant=id;active=TRUE;
llAllowInventoryDrop(TRUE);
llWhisper(0,"/me :: Drop your landmark, texture, notecard and or object in. (hold CTRL while dragging the items in)
");
}
}
}
changed(integer okk)
{
if (okk & (CHANGED_ALLOWED_DROP |CHANGED_INVENTORY))
{ check=1;llSetTimerEvent(2);
}
}
}