conrad Evanier Posted April 1, 2011 Share Posted April 1, 2011 Hi can anyone help me i need to know what to add to my rent script so when someone clicks pay the pay menu gives them a choice of 1 to 4 weeks of set cost rather than having to enter the amount. Example if owner sets rent at L$ 10 a week pay option gives tenant a choice of 10 20 30 40 depending on how many weeks they wont 1 2 3 or 4, any help would be great as im ony a learner as far as scripting goes :) Link to comment Share on other sites More sharing options...
Void Singer Posted April 1, 2011 Share Posted April 1, 2011 llSetPayPrice( PAY_HIDE, [price, 2 * price, 3 * price, 4 * price] ); don't forget to check the amount given for an exact value in the money event Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 1, 2011 Author Share Posted April 1, 2011 Thanks void so now i can hide the default payment options but having trouble linking payment options to the float rentalcost how do i get it to show the coat set by owner?? Link to comment Share on other sites More sharing options...
Void Singer Posted April 1, 2011 Share Posted April 1, 2011 change the word "price" above to "rentalcost" Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 2, 2011 Author Share Posted April 2, 2011 Still just showing payment option as blank, must need to pay_calculate some where lol im not having much luck with this 1 Link to comment Share on other sites More sharing options...
Void Singer Posted April 2, 2011 Share Posted April 2, 2011 tell ya post the code and I'm sure we can work it out =) Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 2, 2011 Share Posted April 2, 2011 It's difficult to tell what exactly goes wrong if you can't s the script - you should post it. Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 2, 2011 Author Share Posted April 2, 2011 Sure heres the rent script with out PAY_HIDE i use a prmcount script and a split list script along side it but this is the 1 that needs a fast pay set up in it so it adjusts to the amount people set on note card as rentalCost. Thanks for your help on this //Optionsvector rentalOffset = <0,0,10>;float updateInterval = 60.0; //secondsstring infoNotecard = ""; //Variablesstring tierName;float rentalCost;integer primCount;key renterID;string renterName;float rentalTime;integer listenQueryID;vector initPos;vector initScale;integer count;integer lineCount;key readKey;string rentalGrade;integer primAllotment; //Constantsfloat ONE_WEEK = 604800.0;float ONE_DAY = 86400.0;float ONE_HOUR = 3600.0; dispString(string value){ llSetText(value, <1,1,1>, 1);}sendReminder(string message){ llInstantMessage(renterID, "Your lease located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") will expire " + message); }saveData(){ list saveData; vector storageVector; saveData += renterID; saveData += renterName; saveData += llRound(rentalTime); storageVector = initPos * 1000; saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">"; storageVector = initScale * 1000; saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">"; llSetObjectDesc(llDumpList2String(saveData, "|"));}string getTimeString(integer time){ integer days; integer hours; integer minutes; integer seconds; days = llRound(time / 86400); time = time % 86400; hours = (time / 3600); time = time % 3600; minutes = time / 60; time = time % 60; seconds = time; return (string)days + " days, " + (string)hours + " hours, " + (string)minutes + " minutes"; // + ":" + (string)seconds; } integer setupDialogListen(){ integer chatChannel = (integer)llFrand(2000000); llListenRemove(listenQueryID); listenQueryID = llListen(chatChannel, "", NULL_KEY, ""); return chatChannel;} updateTimeDisp(){ dispString("Left click for prim count\nLeased by: " + renterName + "\nTime Remaining: " + getTimeString(llRound(rentalTime))); } dispData(){ llSay(0, "========================"); llSay(0, "Rental Space Information"); llSay(0, "========================"); llSay(0, "This space is currently leased by " + renterName); llSay(0, "The current rental price is L$" + (string)((integer)rentalCost) + " per week."); llSay(0, "This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); llSay(0, "Memory Free: " + (string)llGetFreeMemory());}default{ state_entry() { state initialize; }} state initialize{ state_entry() { llSetTimerEvent(300); llOwnerSay("Waiting to obtain Debit Permissions."); llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } run_time_permissions(integer permissions) { //Only wait for payment if the owner agreed to pay out money if (permissions & PERMISSION_DEBIT) { state loadSettings; } } on_rez(integer start_param) { llResetScript(); } timer() { llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } touch_start(integer total_number) { integer x; for (x = 0; x < total_number; x += 1) { if (llDetectedKey(x) == llGetOwner()) { llResetScript(); } } llSay(0, "Waiting to obtain Debit Permissions from Owner."); } state_exit() { llSetTimerEvent(0); llSay(0, "Initialized."); }} state loadSettings{ state_entry() { integer found = FALSE; integer x; count = 0; lineCount = 0; list savedList = llCSV2List(llGetObjectDesc()); if (llGetListLength(savedList) == 4) { rentalGrade = llList2String(savedList, 0); } else { rentalGrade = llGetObjectDesc(); } for (x = 0; x < llGetInventoryNumber(INVENTORY_NOTECARD); x += 1) { if (llGetInventoryName(INVENTORY_NOTECARD, x) == "Settings") { found = TRUE; } } if (found) { llOwnerSay("Reading Settings Notecard..."); readKey = llGetNotecardLine("Settings", lineCount); } else { llOwnerSay("Settings Notecard Not Found."); llResetScript(); } } dataserver(key requested, string data) { integer integerData; float floatData; if (requested == readKey) { if (data != EOF) { if ((llSubStringIndex(data, "#") != 0) && (data != "") && (data != " ")) { integerData = (integer)data; floatData = (float)data; if (count == 0) { tierName = data; } else if (count == 1) { if (integerData >= 0) { rentalCost = integerData; } else { rentalCost = 0; } } else if (count == 2) { if (integerData >= 1) { primCount = integerData; } else { primCount = 1; } } else if (count == 3) { rentalOffset = (vector)data; } else if (count == 4) { infoNotecard = data; } count += 1; } lineCount += 1; readKey = llGetNotecardLine("Settings", lineCount); } else { llOwnerSay("==============="); llOwnerSay("Settings Loaded"); llOwnerSay("==============="); llOwnerSay("Space Name: " + tierName); llOwnerSay("Rental Cost: L$" + (string)llRound(rentalCost)); llOwnerSay("Prims allowed: " + (string)primCount); llOwnerSay("==============="); llOwnerSay("Ready for Service!"); list savedList = llParseString2List(llGetObjectDesc(), ["|"], []); if (llGetListLength(savedList) == 5) { renterID = llList2Key(savedList, 01); renterName = llList2String(savedList, 1); rentalTime = llList2Integer(savedList, 2); initPos = (vector)llList2String(savedList, 3) / 1000; initScale = (vector)llList2String(savedList, 4) / 1000; state rented; } else { renterID = NULL_KEY; renterName = "Nobody"; rentalTime = 0; initPos = llGetPos(); initScale = llGetScale(); state idle; } } } }}state idle{ state_entry() { llSetObjectDesc(""); llSetTexture("rentthisspace", ALL_SIDES); llSetScale(initScale); llSetPos(initPos); llSetTimerEvent(updateInterval); dispString(tierName + "\nLease this space for L$" + (string)llRound(rentalCost) + " per week.\n"+ (string)primCount + " prims\nPay this Box to begin your lease."); } moving_end() { initPos = llGetPos(); } changed(integer change) { if (change & CHANGED_SCALE) { initScale = llGetScale(); } } touch_start(integer num_detected) { integer x; integer chatChannel; for (x = 0; x < num_detected; x += 1) { if (llDetectedKey(x) == llGetOwner()) { llDialog(llGetOwner(), "Owner Options. Select one of the options below...", ["Info", "Reset"], setupDialogListen()); return; } } llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. " + (string)primCount + " prims. Pay this Sign to begin your lease."); for (x = 0; x < num_detected; x += 1) { llGiveInventory(llDetectedKey(x), infoNotecard); } } listen(integer channel, string name, key id, string message) { if (message == "Reset") { llResetScript(); } else if (message == "Info") { llListenRemove(listenQueryID); dispData(); llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. "+ (string)primCount + " prims. Pay this Sign to begin your lease."); llGiveInventory(id, infoNotecard); } } money(key id, integer amount) { if (amount >= rentalCost) { renterID = id; renterName = llKey2Name(renterID); rentalTime = ONE_WEEK * amount / rentalCost; saveData(); llSay(0, "Thank you " + renterName + " for leasing! Your lease will expire in " + getTimeString((integer)rentalTime) + "."); state rented; } else { llSay(0, "This space costs L$" + (string)rentalCost + " to rent."); llGiveMoney(id, amount); } }} state rented{ state_entry() { llSetTexture("rented", ALL_SIDES); llSetScale(<0.5, 0.5, 0.5>); llSetPos(initPos + rentalOffset); updateTimeDisp(); llResetTime(); llSetTimerEvent(updateInterval); } touch_start(integer num_detected) { integer x; key detectedKey; for (x = 0; x < num_detected; x += 1) { detectedKey = llDetectedKey(x); if (detectedKey == llGetOwner()) { llDialog(detectedKey, "Lease Options. Select one of the options below...", ["Info", "Release", "Reset"], setupDialogListen()); } else if (detectedKey == renterID) { llDialog(detectedKey, "Click for info or click Release to end your Lease", ["Info", "Release"], setupDialogListen()); } else { dispData(); llGiveInventory(detectedKey, infoNotecard); } } } money(key id, integer amount) { if ((id == renterID)||(id == llGetOwner())) { float addTime; addTime = ONE_WEEK*amount/rentalCost; rentalTime += addTime; llInstantMessage(id, "Adding " + getTimeString(llRound(addTime)) + " to your lease. Lease Time is Now: " + getTimeString(llRound(rentalTime)) + "."); saveData(); updateTimeDisp(); } else { llGiveMoney(id, amount); llInstantMessage(id, "Left click for prim count\nThis space is currently leased by " + renterName + ". This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); } } listen(integer channel, string name, key id, string message) { integer refundAmount; llListenRemove(listenQueryID); if (message == "Info") { dispData(); llGiveInventory(id, infoNotecard); } else if (message == "Release") { llDialog(id, "Are you sure you want to TERMINATE this rent?", ["Yes", "No"], setupDialogListen()); } else if (message == "Yes") { llInstantMessage(llGetOwner(), "LEASE TERMINATED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has ended."); state idle; } else if (message == "Reset") { llResetScript(); } } timer() { float timeElapsed = llGetAndResetTime(); if (timeElapsed > (updateInterval * 4)) { timeElapsed = updateInterval; } rentalTime -= timeElapsed; saveData(); updateTimeDisp(); //Process Reminders if (rentalTime <= 0) { llInstantMessage(llGetOwner(), "LEASE EXPIRED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has expired."); state idle; } if ((rentalTime <= ONE_DAY)&&(rentalTime >= ONE_DAY - (updateInterval*2))) { sendReminder("in one day."); } else if ((rentalTime <= ONE_HOUR*12)&&(rentalTime >= ONE_HOUR*12 - (updateInterval*2))) { sendReminder("in 12 hours."); } else if ((rentalTime <= ONE_HOUR)&&(rentalTime >= ONE_HOUR - (updateInterval*2))) { sendReminder("in one hour."); } }} Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 2, 2011 Share Posted April 2, 2011 You don't set the price anywhere. Add the line llSetPayPrice(PAY_HIDE, [(integer)rentalCost, 2 * (integer)rentalCost, 3 * (integer)rentalCost, 4 * (integer)rentalCost] ); to the state_entry events of the states idle and rented and it should work. //Optionsvector rentalOffset = <0,0,10>;float updateInterval = 60.0; //secondsstring infoNotecard = "";//Variablesstring tierName;float rentalCost;integer primCount;key renterID;string renterName;float rentalTime;integer listenQueryID;vector initPos;vector initScale;integer count;integer lineCount;key readKey;string rentalGrade;integer primAllotment;//Constantsfloat ONE_WEEK = 604800.0;float ONE_DAY = 86400.0;float ONE_HOUR = 3600.0;dispString(string value){ llSetText(value, <1,1,1>, 1);}sendReminder(string message){ llInstantMessage(renterID, "Your lease located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") will expire " + message); }saveData(){ list saveData; vector storageVector; saveData += renterID; saveData += renterName; saveData += llRound(rentalTime); storageVector = initPos * 1000; saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">"; storageVector = initScale * 1000; saveData += "<" + (string)llRound(storageVector.x) + "," + (string)llRound(storageVector.y) + "," + (string)llRound(storageVector.z) + ">"; llSetObjectDesc(llDumpList2String(saveData, "|"));}string getTimeString(integer time){ integer days; integer hours; integer minutes; integer seconds; days = llRound(time / 86400); time = time % 86400; hours = (time / 3600); time = time % 3600; minutes = time / 60; time = time % 60; seconds = time; return (string)days + " days, " + (string)hours + " hours, " + (string)minutes + " minutes"; // + ":" + (string)seconds; }integer setupDialogListen(){ integer chatChannel = (integer)llFrand(2000000); llListenRemove(listenQueryID); listenQueryID = llListen(chatChannel, "", NULL_KEY, ""); return chatChannel;}updateTimeDisp(){ dispString("Left click for prim count\nLeased by: " + renterName + "\nTime Remaining: " + getTimeString(llRound(rentalTime))); }dispData(){ llSay(0, "========================"); llSay(0, "Rental Space Information"); llSay(0, "========================"); llSay(0, "This space is currently leased by " + renterName); llSay(0, "The current rental price is L$" + (string)((integer)rentalCost) + " per week."); llSay(0, "This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); llSay(0, "Memory Free: " + (string)llGetFreeMemory());}default{ state_entry() { state initialize; }}state initialize{ state_entry() { llSetTimerEvent(300); llOwnerSay("Waiting to obtain Debit Permissions."); llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } run_time_permissions(integer permissions) { //Only wait for payment if the owner agreed to pay out money if (permissions & PERMISSION_DEBIT) { state loadSettings; } } on_rez(integer start_param) { llResetScript(); } timer() { llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } touch_start(integer total_number) { integer x; for (x = 0; x < total_number; x += 1) { if (llDetectedKey(x) == llGetOwner()) { llResetScript(); } } llSay(0, "Waiting to obtain Debit Permissions from Owner."); } state_exit() { llSetTimerEvent(0); llSay(0, "Initialized."); }}state loadSettings{ state_entry() { integer found = FALSE; integer x; count = 0; lineCount = 0; list savedList = llCSV2List(llGetObjectDesc()); if (llGetListLength(savedList) == 4) { rentalGrade = llList2String(savedList, 0); } else { rentalGrade = llGetObjectDesc(); } for (x = 0; x < llGetInventoryNumber(INVENTORY_NOTECARD); x += 1) { if (llGetInventoryName(INVENTORY_NOTECARD, x) == "Settings") { found = TRUE; } } if (found) { llOwnerSay("Reading Settings Notecard..."); readKey = llGetNotecardLine("Settings", lineCount); } else { llOwnerSay("Settings Notecard Not Found."); llResetScript(); } } dataserver(key requested, string data) { integer integerData; float floatData; if (requested == readKey) { if (data != EOF) { if ((llSubStringIndex(data, "#") != 0) && (data != "") && (data != " ")) { integerData = (integer)data; floatData = (float)data; if (count == 0) { tierName = data; } else if (count == 1) { if (integerData >= 0) { rentalCost = integerData; } else { rentalCost = 0; } } else if (count == 2) { if (integerData >= 1) { primCount = integerData; } else { primCount = 1; } } else if (count == 3) { rentalOffset = (vector)data; } else if (count == 4) { infoNotecard = data; } count += 1; } lineCount += 1; readKey = llGetNotecardLine("Settings", lineCount); } else { llOwnerSay("==============="); llOwnerSay("Settings Loaded"); llOwnerSay("==============="); llOwnerSay("Space Name: " + tierName); llOwnerSay("Rental Cost: L$" + (string)llRound(rentalCost)); llOwnerSay("Prims allowed: " + (string)primCount); llOwnerSay("==============="); llOwnerSay("Ready for Service!"); list savedList = llParseString2List(llGetObjectDesc(), ["|"], []); if (llGetListLength(savedList) == 5) { renterID = llList2Key(savedList, 01); renterName = llList2String(savedList, 1); rentalTime = llList2Integer(savedList, 2); initPos = (vector)llList2String(savedList, 3) / 1000; initScale = (vector)llList2String(savedList, 4) / 1000; state rented; } else { renterID = NULL_KEY; renterName = "Nobody"; rentalTime = 0; initPos = llGetPos(); initScale = llGetScale(); state idle; } } } }}state idle{ state_entry() { llSetObjectDesc(""); llSetTexture("rentthisspace", ALL_SIDES); llSetScale(initScale); llSetPos(initPos); llSetTimerEvent(updateInterval); llOwnerSay((string)rentalCost); dispString(tierName + "\nLease this space for L$" + (string)llRound(rentalCost) + " per week.\n"+ (string)primCount + " prims\nPay this Box to begin your lease."); } moving_end() { initPos = llGetPos(); } changed(integer change) { if (change & CHANGED_SCALE) { initScale = llGetScale(); } } touch_start(integer num_detected) { integer x; integer chatChannel; for (x = 0; x < num_detected; x += 1) { if (llDetectedKey(x) == llGetOwner()) { llDialog(llGetOwner(), "Owner Options. Select one of the options below...", ["Info", "Reset"], setupDialogListen()); return; } } llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. " + (string)primCount + " prims. Pay this Sign to begin your lease."); for (x = 0; x < num_detected; x += 1) { llGiveInventory(llDetectedKey(x), infoNotecard); } } listen(integer channel, string name, key id, string message) { if (message == "Reset") { llResetScript(); } else if (message == "Info") { llListenRemove(listenQueryID); dispData(); llSay(0, "Lease this space for L$" + (string)llRound(rentalCost) + " per week. "+ (string)primCount + " prims. Pay this Sign to begin your lease."); llGiveInventory(id, infoNotecard); } } money(key id, integer amount) { if (amount >= rentalCost) { renterID = id; renterName = llKey2Name(renterID); rentalTime = ONE_WEEK * amount / rentalCost; saveData(); llSay(0, "Thank you " + renterName + " for leasing! Your lease will expire in " + getTimeString((integer)rentalTime) + "."); state rented; } else { llSay(0, "This space costs L$" + (string)rentalCost + " to rent."); llGiveMoney(id, amount); } }}state rented{ state_entry() { llSetTexture("rented", ALL_SIDES); llSetScale(<0.5, 0.5, 0.5>); llSetPos(initPos + rentalOffset); updateTimeDisp(); llResetTime(); llSetTimerEvent(updateInterval); } touch_start(integer num_detected) { integer x; key detectedKey; for (x = 0; x < num_detected; x += 1) { detectedKey = llDetectedKey(x); if (detectedKey == llGetOwner()) { llDialog(detectedKey, "Lease Options. Select one of the options below...", ["Info", "Release", "Reset"], setupDialogListen()); } else if (detectedKey == renterID) { llDialog(detectedKey, "Click for info or click Release to end your Lease", ["Info", "Release"], setupDialogListen()); } else { dispData(); llGiveInventory(detectedKey, infoNotecard); } } } money(key id, integer amount) { if ((id == renterID)||(id == llGetOwner())) { float addTime; addTime = ONE_WEEK*amount/rentalCost; rentalTime += addTime; llInstantMessage(id, "Adding " + getTimeString(llRound(addTime)) + " to your lease. Lease Time is Now: " + getTimeString(llRound(rentalTime)) + "."); saveData(); updateTimeDisp(); } else { llGiveMoney(id, amount); llInstantMessage(id, "Left click for prim count\nThis space is currently leased by " + renterName + ". This space will be open for lease in " + getTimeString(llRound(rentalTime)) + "."); } } listen(integer channel, string name, key id, string message) { integer refundAmount; llListenRemove(listenQueryID); if (message == "Info") { dispData(); llGiveInventory(id, infoNotecard); } else if (message == "Release") { llDialog(id, "Are you sure you want to TERMINATE this rent?", ["Yes", "No"], setupDialogListen()); } else if (message == "Yes") { llInstantMessage(llGetOwner(), "LEASE TERMINATED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has ended."); state idle; } else if (message == "Reset") { llResetScript(); } } timer() { float timeElapsed = llGetAndResetTime(); if (timeElapsed > (updateInterval * 4)) { timeElapsed = updateInterval; } rentalTime -= timeElapsed; saveData(); updateTimeDisp(); //Process Reminders if (rentalTime <= 0) { llInstantMessage(llGetOwner(), "LEASE EXPIRED: leased by " + renterName + " located in " + llGetRegionName() + " (" + (string)initPos.x + "," + (string)initPos.y + "," + (string)initPos.z + ") has expired."); state idle; } if ((rentalTime <= ONE_DAY)&&(rentalTime >= ONE_DAY - (updateInterval*2))) { sendReminder("in one day."); } else if ((rentalTime <= ONE_HOUR*12)&&(rentalTime >= ONE_HOUR*12 - (updateInterval*2))) { sendReminder("in 12 hours."); } else if ((rentalTime <= ONE_HOUR)&&(rentalTime >= ONE_HOUR - (updateInterval*2))) { sendReminder("in one hour."); } }} Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted April 2, 2011 Share Posted April 2, 2011 One thing I spotted, although there may be other issues: in the loadSettings state, dataserver event-handler, at the EOF the original had "renterID = llList2Key(savedList, 01);" and it's still here. I assume this is meant to be just '0' Link to comment Share on other sites More sharing options...
Darkie Minotaur Posted April 2, 2011 Share Posted April 2, 2011 *grins* I haven't gone through the complete code - there could be other 'not so nice' things in it - but it compiles and runs in the aspect that the OP asked. Link to comment Share on other sites More sharing options...
PeterCanessa Oh Posted April 2, 2011 Share Posted April 2, 2011 For sure - tl;dr here too. That one just grabbed my attention somehow though Link to comment Share on other sites More sharing options...
Void Singer Posted April 2, 2011 Share Posted April 2, 2011 ... and see... posted code, and suddenly 3 people helping and much faster than I could get back to it... Link to comment Share on other sites More sharing options...
conrad Evanier Posted April 2, 2011 Author Share Posted April 2, 2011 Nice 1 Darkie it now works great and no other probs, lol the mistake i made was not puting the line in on state rented i just put it in on idle lol yeh wel am learning and thanks for all you help am amazed at how quick u all jumped on it cool. Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now