Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need HELP: Modifiying money split script.

Amara Twilight
Registered User
Join date: 16 Feb 2004
Posts: 47
10-29-2008 23:39
Hi there.

I need some help figuring how to put a fast pay box into this script and hiding all but the single pay button. No idea how to do this as this script seems complicated to me with my very simple scripting skills.

Thank you for your help.

CODE

//Sales Assistant v1.1
//by Nick Fortune - 09/01/2004

//This script makes it possible to sell things out of boxes and split the profit with a partner.
//The info about the objects price is read from the object's description.
//You can set the description on the GENERAL TAB just like the Object Name.

//Example Description: 100$ Super Mega Awesome Prim Thinger

//The script reads the price from the description so long as you have it in the format above.
//You must put "price$ info". The dollar sign must be in there for the script to work.
//-----Do Not Remove Header


//key gPartner = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // ############# PUT YOUR PARTNER'S KEY HERE. #############
//where the x's are your partner's key


key gPartner = ""; // ############# PUT YOUR PARTNER'S KEY HERE. #############


///----------------Don't need to change anything below this line-------------------

key gOwner;
integer gPrice;
integer gCut;
integer gPerms = FALSE;
string gObject;


default {
state_entry() {
llWhisper(0, (string)gPartner);
gOwner = llGetOwner();
list Parsed = llParseString2List(llGetObjectDesc(), ["$"], []);
gPrice = llList2Integer(Parsed, 0);
if (!gPrice) {
llInstantMessage(gOwner, "Error: Please set object description to ''price$ info about object''. Touch to reset when ready.");
}
else {
if (gPartner != "") {
gCut = llRound(gPrice / 2);
}
gObject = llGetInventoryName(INVENTORY_OBJECT,0);
llRequestPermissions(gOwner,PERMISSION_DEBIT);
}
}

on_rez(integer passed) {
if(llDetectedKey(0) != llGetOwner()) {
llResetScript();
}
}

run_time_permissions(integer type)
{
if ((type & PERMISSION_DEBIT) != PERMISSION_DEBIT) {
gPerms = FALSE;
llInstantMessage(gOwner, "I require debit permissions to function.");
llRequestPermissions(gOwner,PERMISSION_DEBIT);
}
else {
gPerms = TRUE;
llInstantMessage(gOwner, "I have aquired debit permissions from "+llKey2Name(gOwner)+".");
if ((gPrice) && (gObject != "")) {
if (gPartner != "") {
llInstantMessage(gOwner, "Selling "+gObject+" for "+(string)gPrice+"$L. [Partner receives "+(string)gCut+"$L cut.]");
}
else {
llInstantMessage(gOwner, "Selling "+gObject+" for "+(string)gPrice+"$L. [NO Partner Defined.]");
}
}
else {
llInstantMessage(gOwner, "I have permissions, but your box is missing contents or missing a price.");
llInstantMessage(gOwner, "Fix error and touch to reset when ready.");
}
}
}

touch_start(integer total_number) {
if (llDetectedKey(0) == llGetOwner()) {
llResetScript();
}
else {
llWhisper(0, gObject+" - $"+(string)gPrice+"L. Right click and pay amount to purchase.");
}
}

money(key giver, integer amount) {
if (gPerms == TRUE) {
if (amount < gPrice) {
llSay(0, gObject+" costs L$" + (string) gPrice);
llSay(0, "You paid $L"+(string)amount+", which is not enough!");
llGiveMoney(giver, amount);
}
else {
llSay(0, "Thank you for your purchase!");
llGiveInventory(giver, gObject);
if (amount > gPrice) {
llGiveMoney(giver, amount - gPrice);
}

if (gPartner != "") {
llGiveMoney(gPartner, gCut);
}
}
}
}
}
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
10-30-2008 01:54
The trick is to set llSetPayPrice()...

http://www.lslwiki.net/lslwiki/wakka.php?wakka=llSetPayPrice

This script just splits the price evenly between you and your partner - if you want to have different shares, you have to do some other math...

HTH


CODE

//Sales Assistant v1.1
//by Nick Fortune - 09/01/2004

//This script makes it possible to sell things out of boxes and split the profit with a partner.
//The info about the objects price is read from the object's description.
//You can set the description on the GENERAL TAB just like the Object Name.

//Example Description: 100$ Super Mega Awesome Prim Thinger

//The script reads the price from the description so long as you have it in the format above.
//You must put "price$ info". The dollar sign must be in there for the script to work.
//-----Do Not Remove Header


//key gPartner = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; // ############# PUT YOUR PARTNER'S KEY HERE. #############
//where the x's are your partner's key


key gPartner = ""; // ############# PUT YOUR PARTNER'S KEY HERE. #############


///----------------Don't need to change anything below this line-------------------

key gOwner;
integer gPrice;
integer gCut;
integer gPerms = FALSE;
string gObject;


default {
state_entry() {
llWhisper(0, (string)gPartner);
gOwner = llGetOwner();
list Parsed = llParseString2List(llGetObjectDesc(), ["$"], []);
gPrice = llList2Integer(Parsed, 0);
if (!gPrice) {
llInstantMessage(gOwner, "Error: Please set object description to ''price$ info about object''. Touch to reset when ready.");
}
else {
if (gPartner != "") {
gCut = llRound(gPrice / 2);
}
gObject = llGetInventoryName(INVENTORY_OBJECT,0);
llRequestPermissions(gOwner,PERMISSION_DEBIT);
}
}

on_rez(integer passed) {
if(llDetectedKey(0) != llGetOwner()) {
llResetScript();
}
}

run_time_permissions(integer type)
{
if ((type & PERMISSION_DEBIT) != PERMISSION_DEBIT) {
gPerms = FALSE;
llInstantMessage(gOwner, "I require debit permissions to function.");
llRequestPermissions(gOwner,PERMISSION_DEBIT);
}
else {
gPerms = TRUE;
llInstantMessage(gOwner, "I have aquired debit permissions from "+llKey2Name(gOwner)+".");
if ((gPrice) && (gObject != "")) {
if (gPartner != "") {
llInstantMessage(gOwner, "Selling "+gObject+" for "+(string)gPrice+"$L. [Partner receives "+(string)gCut+"$L cut.]");
}
else {
llInstantMessage(gOwner, "Selling "+gObject+" for "+(string)gPrice+"$L. [NO Partner Defined.]");
}

// Add the pay-buttons here:

llSetPayPrice(PAY_HIDE, [gPrice]);
}
else {
llInstantMessage(gOwner, "I have permissions, but your box is missing contents or missing a price.");
llInstantMessage(gOwner, "Fix error and touch to reset when ready.");
}
}
}

touch_start(integer total_number) {
if (llDetectedKey(0) == llGetOwner()) {
llResetScript();
}
else {
llWhisper(0, gObject+" - $"+(string)gPrice+"L. Right click and pay amount to purchase.");
}
}

money(key giver, integer amount) {
if (gPerms == TRUE) {
if (amount < gPrice) {
llSay(0, gObject+" costs L$" + (string) gPrice);
llSay(0, "You paid $L"+(string)amount+", which is not enough!");
llGiveMoney(giver, amount);
}
else {
llSay(0, "Thank you for your purchase!");
llGiveInventory(giver, gObject);
if (amount > gPrice) {
llGiveMoney(giver, amount - gPrice);
}

if (gPartner != "") {
llGiveMoney(gPartner, gCut);
}
}
}
}
}
Amara Twilight
Registered User
Join date: 16 Feb 2004
Posts: 47
10-30-2008 12:47
thank you again Haruki. You are a life saver. :) I see what you did so learned something :)