Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Vending script

Wednesday Grimm
Ex Libris
Join date: 9 Jan 2003
Posts: 934
06-10-2003 19:51
CODE

// vendor
// Wednesday Grimm
// June 10, 2003
//
// Simple vending script, gives correct change.

integer gPrice = 5; // cost of the item

// name of the item in object's inventory, to vend
string itemName = "test_note";

// two summary lines to describe the object
string summary1 = "this is a test note, it tests this script";
string summary2 = "it is very interesting. Cost is $5";

// give the item to a customer
dispense(key toWhom)
{
llGiveInventory(toWhom, itemName);
}

default
{
state_entry()
{
// we need this permission to give change
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}

touch_end(integer total_number)
{
// if someone touches object describe what's for sale
llWhisper(0, summary1);
llWhisper(0, summary2);
}

money(key id, integer amt)
{
if (amt >= gPrice)
{
// customer has given us at least enough money
amt -= gPrice;
dispense(id);
}
if (amt > 0) // give back change
{
llGiveMoney(id, amt);
}
}
}
_____________________
Sarcasm meter:
0 |-----------------------*-| 10
Rating: Awww Jeeze!
Wolfgang Bach
Registered User
Join date: 9 Jan 2003
Posts: 7
Original Thread
04-25-2004 19:16
/15/36/3038/1.html


Thanks Wednesday, I just used this for the first time, and it works perfectly. Now I'm selling my first items, some men's ware.

Wolf
Melanie Morgan
Junior Member
Join date: 24 Apr 2004
Posts: 19
need help??
05-04-2004 21:03
can someone please explain exactly about a selling vendor script sorry, i didnt quite understand,
heard we have to take a picture first?? can you explain how step by step to add items in a vendor and start it up, reset it ??? thanks MELI ....
Dragon Steele
Artist/conservationist
Join date: 3 Jan 2005
Posts: 183
05-04-2005 07:48
Please, could you give me some clarification if you do not mind. Is this a single item vending script or an multi-item vendor? Forgive Me but when it comes to scripting I am quite illiterate.

Thank you

:)
_____________________
Boycot the spam farms and the ads on them. Ban the spamers from your land. Look for the clocktower network for a blacklist to put on you land that is grid wide.
Jacqueline Bancroft
Registered User
Join date: 10 Sep 2004
Posts: 19
05-16-2005 13:37
This is a vendor program for a single item. This is how it works:

You rez a cube and pretty it up.. maybe put a texture of what you're selling on the side.

Put the item that you want to sell into the cube you made.

Put this script inside the cube you made, and then open up the script to edit it.

Where it says gPrice, put the price of the item you want to sell after the equal sign.

Where it says itemName, put the item name of the item that you want to sell after the equal sign. Be very aware that the script is case sensitive, so make sure you spell it correctly. For example, "My Object" is different than "my object".

Where it says summary1 and summary 2, fill in a description of the item what you wish to sell. make sure that you surround the description with quotation marks, or else the script will go wonky. When a potential customer touches (clicks) on your box vendor, your box vendor will whisper summary1 and summary2 to them.

That's about it. Be sure to thank Wednesday if you use this script. :)
Dragon Steele
Artist/conservationist
Join date: 3 Jan 2005
Posts: 183
05-18-2005 20:07
From: Jacqueline Bancroft
This is a vendor program for a single item. This is how it works:

You rez a cube and pretty it up.. maybe put a texture of what you're selling on the side.

Put the item that you want to sell into the cube you made.

Put this script inside the cube you made, and then open up the script to edit it.

Where it says gPrice, put the price of the item you want to sell after the equal sign.

Where it says itemName, put the item name of the item that you want to sell after the equal sign. Be very aware that the script is case sensitive, so make sure you spell it correctly. For example, "My Object" is different than "my object".

Where it says summary1 and summary 2, fill in a description of the item what you wish to sell. make sure that you surround the description with quotation marks, or else the script will go wonky. When a potential customer touches (clicks) on your box vendor, your box vendor will whisper summary1 and summary2 to them.

That's about it. Be sure to thank Wednesday if you use this script. :)


thank you :)
_____________________
Boycot the spam farms and the ads on them. Ban the spamers from your land. Look for the clocktower network for a blacklist to put on you land that is grid wide.
Artemis Maelstrom
Registered User
Join date: 26 Sep 2004
Posts: 6
09-13-2005 20:41
Terrific vendor, I modified it to IM me when an item is bought and IM me with how much i have made in total when an item is purchased.
Ben Stravinsky
Second Life Resident
Join date: 7 Nov 2004
Posts: 149
I'd check this script again
10-30-2005 10:22
I have found that this script has an error in it, and allows people to purchase items for the wrong amount of money.

Simple pay the vendor under the correct amount, and it will tell you that you need to enter more money. Enter the rest to bring your payment up to the correct amount and you will recieve your item. From this point on you can now purchase the item over and over again for 1$.

Ihave jsut sat in world testing this, and either i have an odd bug. Or i'm right ^^

I hope i'm wrong as a lot of people are using this item.
Tami Amat
*winks*
Join date: 7 Mar 2007
Posts: 114
I know this is kind of an old post, but...
06-14-2007 13:54
I tried the script. What worked is taking out the wording
CODE
 and 
before and after the actual script. But, I'm not sure this is working. I can right click on it and then select open. The contents are then delivered. I do have it set to L$1 and it asks for no money. That can't be right, right?

Anyone care to update this post?

Thanks a bunch!

Tami
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
06-14-2007 18:11
Tami, you can do all sorts of things with this vendor that an ordinary customer cannot, simply because it belongs to you - edit it and add or remove contents, open it as you mentioned, any number of things. Nobody else will be able to do those things though.

I should mention that I haven't looked over the code so I can't vouch for whether the thing works or not (and the post above yours seems to indicate some problem with the script) so you might approach this with some care. But what you experienced is not a problem in and of itself, it's just how the SL permissions system works with things you yourself own.
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-14-2007 19:22
If you are worried about giving change, you can do the following in the default state:

state_entry()
{
// we need this permission to give change
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}


This just needs to be changed to:

state_entry()
{
llSetPayPrice( PAY_HIDE, [ gPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE ] );
}

This will set the pay price ( gPrice ) as the only option for payment in your pay dialog. Doing this, you do not need to give a debit permission. This also means that some of the following code is a bit redundant. Always good to keep in, though, as you may decide to change it later back to the original state.
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
06-14-2007 22:04
From: Jim Guyot

This will set the pay price ( gPrice ) as the only option for payment in your pay dialog. Doing this, you do not need to give a debit permission. This also means that some of the following code is a bit redundant. Always good to keep in, though, as you may decide to change it later back to the original state.


No, you *must* keep it in.

It's mentioned several times on the Wiki that llSetPayPrice offers a nicer user interface, but it does NOT force the user to be only able to give one of the amounts you specify.
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-14-2007 22:13
Actually that isn't true.

If you would like to see it in action, all of my vendors use that code:

llSetPayPrice( PAY_HIDE, [ iPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE ] );


It only allows one payment, which is iPrice. You can visit either of my stores to see examples of it in use. One is at Jade's Jazz Mall in Haeoreum and the other is at Jade's Jazziest Mall in Rothenburg. If you'd like a landmark to either, please IM me in world and I will get one to you as soon as possible.

It is a good idea to keep the debit permissions, just in case you need to add a more robust system of payment. It is not required, although all of my vendors have it as a precaution.
ab Vanmoer
Registered User
Join date: 28 Nov 2006
Posts: 131
06-14-2007 22:26
From: Jim Guyot
If you are worried about giving change, you can do the following in the default state:

state_entry()
{
// we need this permission to give change
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}


This just needs to be changed to:

state_entry()
{
llSetPayPrice( PAY_HIDE, [ gPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE ] );
}

This will set the pay price ( gPrice ) as the only option for payment in your pay dialog. Doing this, you do not need to give a debit permission. This also means that some of the following code is a bit redundant. Always good to keep in, though, as you may decide to change it later back to the original state.

Even if you use the llSetPayPrice you still need to check the actual amount paid in and be prepared to give change. The wiki entry for llSetPayPrice carries a huge red warning about this.

For anyone who doesn't want to hack the code for their own purpose, I do sell a multi item vendor, it includes payment sharing, gives notecards, and maintains a list of recent sales.
I sell it for L$40 more as a service than as a money making item.
http://slurl.com/secondlife/Monowai/240/71/76
or use search to find Ab's Emporium