Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: EZ One Object Vendor

Devon Cassidy
Registered User
Join date: 20 Mar 2004
Posts: 11
01-10-2005 19:18
CODE
// EZ Single Object Vendor System
// Author: Devon Cassidy
// This script is to be used by anyone in their own One Object Vendor Systems.
// Feel free to do as you please with this script.

integer price = 0; //Price of the object goes here, change to whatever you want
string item = "item name here"; // Write the EXACT name of the object you want to sell
string wrong = "Sorry, that is not the correct pricet"; // This is the message your vendor will say when the person underpays the vendor
string over = "You have overpaid, here is your change"; //This is the message your vendor will say when a person overpays the vendor
string thank = "Thank you for your purchase"; //This is a message thanking your buyer for purchasing your object, its very courteous for you to thank them after they buy something
default
{
on_rez(integer total_number)
{
llResetScript();
}
state_entry()
{
llWhisper(0, "EZ Vendor!");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); //Make sure you click YES when the debit dialog pops up or youll have some very unhappy customers >_<. This insures that they will get their change back if they overpay or underpay
}
money(key id, integer amount)
{
if(amount < price)
{
llSay(0, wrong);
llGiveMoney(id, amount);
}
if(amount > price)
{
llSay(0, over);
llGiveMoney(id, amount - price);
llGiveInventory(llDetectedKey(0), item);
}
if(amount = price)
{
llSay(0, thank);
llGiveInventory(llDetectedKey(0), item);
}
}
}


=========================================================

If you find any problems in this script please spot them out and fix them for me. I had
to write this in SciTE ez which does not compile the scripts but im pretty sure that
this should work ^_^.
Hank Ramos
Lifetime Scripter
Join date: 15 Nov 2003
Posts: 2,328
01-14-2005 18:49
You can also place your item into the contents of a prim, set a price and to sell the contents, and not have to use a script at all to setup a very simple vendor.
Screwtape Foulsbane
Registered User
Join date: 30 Dec 2007
Posts: 134
03-30-2008 09:28
Excellent Script but if you add;

llSetPayPrice(PAY_DEFAULT, [price,PAY_HIDE,PAY_HIDE,PAY_HIDE]);

It changes the pay dialog box to present only 1 pay button with the exact price.

S.
_____________________

Silly & Sane, home of Mr. Pig and the Wearable Chair.
http://slurl.com/secondlife/Teal%20Island/88/210/25
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
05-21-2008 07:31
:)
_____________________
i've got nothing. ;)