Second Life Copybot
Sales Assistant Script - Printable Version

+- Second Life Copybot (https://secondlifecopybot.com)
+-- Forum: SECOND LIFE PRODUCTS (https://secondlifecopybot.com/forum-1.html)
+--- Forum: SCRIPTS (https://secondlifecopybot.com/forum-1022.html)
+---- Forum: SCRIPTS (https://secondlifecopybot.com/forum-8.html)
+----- Forum: Business Scripts (https://secondlifecopybot.com/forum-44.html)
+----- Thread: Sales Assistant Script (/thread-604.html)



Sales Assistant Script - steadymobbin - 02-18-2013

//Sales Assistant v1.3
//Do not remove the following information...

//Originally Coded by Nick Fortune - 09/01/2004
//Updated by Chaiboy Rang - 07/29/2007
//Updated by Chimera Firecaster - 05/01/2010

//This script allows you to sell items and split the profit with a partner.

//To use this script, you'll need to do the following:
// 1. Make a Vendor Sign with an image of the item(s) you are selling.
// 2. Rez a box and place the item or items being sold in the "Contents" of
// the box.
// 3. Take the box back into your inventory.
// 4. Then drag the box out of your inventory and place it in the "Contents" of // the Vendor Sign.
// 5. Along with the box, place a copy of this script in the "Contents" of
// the Vendor Sign.

//The script obtains the price of the item from the Vendor Sign's DESCRIPTION
// Remember that DESCRIPTION is found in the GENERAL tab along with the NAME
// that you assigned to the Vendor Sign (if any).

//Here's an example of how you want the DESCRIPTION to read:
// 100$ Men's Plaid Boxer Shorts

//The script will read the price from the DESCRIPTION, as long as you have
// formatted it as follows: "Price$ Name-of-Item". The dollar sign ($)
// must be there for the script to work properly. Note that the Name-of-Item
// which follows Price$ is not important to the script. That part of the
// description can be anything that you. What's important is Price$.

//In addition to indicating the price in the description, you need to enter
// two values below. FIRST, you need to enter your partner's UUID key
// If you don't know what that is, do a search on web for information
// on how to obtain it. Or you may visit:

[To see links please register here]

// for a free script to obtain an avatar's UUID key.
// SECONDLY, you need to enter the percentage of the total that you are paying
// your partner. The default percentage is 50%. You can make this whatever
// you and your partner have mutually agreed upon. Enter the value as a
// decimal. For example, if you are paying your partner 40%, enter the
// value as .40

//Note: this is a FREE script. It is given generously to the Second Life
// community without the expectation of anything in return. It may be
// distributed, but please do not charge for it. That's bad form and will
// most certainly bring bad karma to those who dishonor the kindness of others.

//-----Do Not Remove Above Header

//INFORMATION THAT YOU NEED TO ADD . . .

// 1. PUT YOUR PARTNER'S KEY IN THE NEXT LINE: where the x's are your partner's key
key gPartner = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

// 2. PUT THE PERCENTAGE YOU WISH TO PAY YOUR PARTNER IN THE NEXT LINE
float gPercent = .50;

///----------------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. This only sells a object so please put clothing,r bodyparts or multiple items in a bag or box. ''. Touch to reset when ready.");
}
else {
llSetPayPrice(gPrice, [gPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
if (gPartner != "") {
gCut = llRound(gPrice * gPercent);
}
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);
}
}
}
}
}