Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Limit Sales of an Item

Sandy Schnook
Official Dorkette
Join date: 31 Dec 2005
Posts: 60
06-07-2007 02:47
I will soon be opening a small artsy type shop and want to limit the sales of some of the items to 25 or 50. I've looked at the Knowledge base and cruised the forums, but can't seem to find any ideas in how to do this. All I can think of so far is count how many copies I sell, then remove the item, and I know there's got to be an easier way. Any help would be appreciated. Thanks in advance.
Matthew Dowd
Registered User
Join date: 30 Jan 2007
Posts: 1,046
06-07-2007 02:55
The easiest way would be to include the text "1 of 25" in the texture of the first object, "2 of 25" in the second etc. and create 25 unique objects (set to no copy obviously)
Aleister Montgomery
Minding the gap
Join date: 30 Apr 2006
Posts: 846
06-07-2007 04:37
// One way to do this is a vendor script. Create your vendor prim, drop your sales item into
// its inventory, copy the contents of this post, paste it into a script inside the vendor,
// and change the top lines of this script (item name, price etc.).
// Payments are made with right-click + "Buy".

// The vendor will ask you for permission to take money from you. Don't be afraid, the script
// needs this permission in order to make payments to your account. Have someone with LSL
// knowledge look over this script, if you want to be sure what it does.

// LIMITED EDITION VENDOR SCRIPT BY ALEISTER MONTGOMERY (A.K.A. ISHTARA ROTHSCHILD)

string Company_Name = "Gallery Gallivant" ; //Name of your company, shop or gallery in quotes
string Item_Name = "Something Yellowish with Purple Dots" ; //Name of the sales item in quotes
integer Price = 180 ; //Price in L$
integer Copies = 3 ; //Number of copies to sell
integer Sold = 0 ; //Don't change this, increments automatically

startup() //Asks for permission to handle payments, sets the price
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [Price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
set_title();
}

set_title() //Sets the vendor name and the floating text
{
integer temp = Sold + 1;
integer left = Copies - Sold;
string title = "'"+Item_Name+"'"; //Item name is set in quotes
llSetObjectName(title+", copy no. "+(string)temp+" of "+(string)Copies);
//Vendor name changed to 'Title', copy no. X of X
llSetText(title+", limited to "+(string)Copies+" copies, "+(string)left+" left",
<1,1,1>,1);
//Floating text changed to 'Title', limited to X copies, X left
}

default
{
state_entry()
{
startup(); //Execute startup and set_title when the script starts running...
}
on_rez(integer param)
{
startup(); //...and also when the vendor is picked up and rezzed again.
}
money(key id, integer amount) //If a payment is made...
{
if (amount == Price)
//amount != price can't happen, since there's only a payment button and no input field.
//Just an unneeded precaution.
{
++Sold; //Increment no. of sold copies by 1
llWhisper(0,Company_Name+" thanks you for your purchase!
Please stand by while the item is delivered, and please click 'Accept'.";);
llGiveInventory(id, Item_Name); //Hand out the ware
llWhisper(0,"You purchased copy no. "+(string)Sold+" of a limited edition of
only "+(string)Copies+" copies. The item can be found in your Objects folder.";);
if (Sold == Copies) state sold_out;
//Stop vendor from working when all copies have been sold.
else set_title(); //Change the floating text to display the no. of copies left
}
}
}

state sold_out
{
state_entry()
{
string title = "'"+Item_Name+"'"; //Item name is set in quotes
llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
//Disable further payments
llSetObjectName(title+" - sold out!";);
llSetText(title+" - sold out! We are sorry for the inconvenience.",<1,1,1>,1);
//Change object name and floating text to notify the customers
llInstantMessage(llGetOwner(), "All "+(string)Copies+" copies of the item "+
title+" have been sold. The vendor has been disabled.";);
//Notify the vendor owner
}
}
Aleister Montgomery
Minding the gap
Join date: 30 Apr 2006
Posts: 846
06-07-2007 04:48
I'd trade you a copy of the vendor script inworld, if LL had not ruined the search menu. I would also put the script above in a better readable format, if LL had not broken the BB code formatting of the forums. Can't speak for LL, but... sorry about that :)
Benja Kepler
Registered User
Join date: 16 Dec 2006
Posts: 53
06-07-2007 07:57
the 'bare bones' of Aleister's solution is:-

CODE

integer items_sold;
integer price;
default
{
state_entry()
{
price = 1;
items_sold = 0;
llSetPayPrice(price,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}
money(key purchaser_id, integer amount_paid)
{
items_sold = items_sold + 1;
if(items_sold > 2)
{
llWhisper(0,"Last one sold");
llSetPayPrice(PAY_HIDE,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
}
}
}


so, after the 3rd one is sold, the price is removed on the Pay... dialog box by the PAY_HIDE constant. Note that the object should not have its 'For Sale' box checked so that only the 'Pay...' appears on the pie menu.

instead of the llWhisper, you could use llDie() to delete the object altogether, or llSetTexture to put a 'Sold Out' texture onto the object.
Sandy Schnook
Official Dorkette
Join date: 31 Dec 2005
Posts: 60
Thank you all
06-07-2007 11:29
This looks exactly like what I need, though I'm not much of a scripter myself. However, my partner and his best friend are great with scripts, so whatever I'm not sure of, I know one of them will be able to walk me through. You'd think after 1 1/2 years in SL I'd know what I was doing. But that's my constant enjoyment with SL, I am always learning something new. Thanks again, for all your help, that's another joy of SL, lots of great folks.