Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Vending script

Ryen Jade
This is a takeover!
Join date: 21 Jun 2003
Posts: 1,329
01-30-2004 22:09
This is a script I wrote a few days ago. This basically allows the person to drop in a said amount of cash (defined under Qeamount) and the avatar buying the item and simply pay you to the object. This supports only one object being sold at a time. Yes I know a script similar to this one was released a while ago, this is simply my version of it.
CODE

//Script by Ryen Jade, with help from david linden
//You may not resell this scipt
//Change amount here to change the price
//Copyright 2004-2005
integer Qeamount = 550;
integer balance = 0;
string object;

check()
{
string object = llGetInventoryName(INVENTORY_OBJECT,0);
integer count = llGetInventoryNumber(INVENTORY_OBJECT);


if(count > 0)
{
llWhisper(0, "I will sell " + (string)object + " for " + (string)Qeamount + "L$");
llSetObjectName(object);
}
else
{
llSetObjectName("No object for sale");
llWhisper(0,"No object currently for sale");
}
}
default
{
on_rez(integer null)
{
string object = llGetInventoryName(INVENTORY_OBJECT,0);
check();
}
state_entry()
{

string object = llGetInventoryName(INVENTORY_OBJECT,0);
llWhisper(0, "I will sell " + (string)object + " for " + (string)Qeamount + "L$");
llSetText("Pay me for "+object+",im selling it for "+(string)Qeamount+"L$!",<1,1,0>,TRUE);

}
touch_start(integer null)
{
string object = llGetInventoryName(INVENTORY_OBJECT,0);
llWhisper(0, "I will sell " + (string)object + " for " + (string)Qeamount + "L$");
llSleep(3);
}
changed(integer null)
{
check();
}
money(key id, integer amount)
{
string object = llGetInventoryName(INVENTORY_OBJECT,0);
balance+=amount;
if(balance >= Qeamount)
{
llGiveInventory(id,llGetInventoryName( INVENTORY_OBJECT,0));
llWhisper(0,"Thanks for your purchase of the " + object);
}
else
{
llWhisper(0,"You need to enter more money for this object!");
}
}
}


edit-fixed a small presentation error, so that it can be copied and pasted into a script. (it was the forum rendering engine, not your script ;) )
si Money
The nice demon.
Join date: 21 May 2003
Posts: 477
01-31-2004 09:55
So, if i'm reading your money event right (it's early, bear with me). Only one person ever has to pay the L$550. Everyone subsequently can pay $1 and receive the object?

You probably also want to check for people who accidentally pay too much.

I'm not quite sure I understand how this is really a vendor, the sell contents function would do more than this one does presently.
_____________________
Like a soul without a mind
In a body without a heart
I'm missing every part

-- Progress --
Catherine Omega: Yes, but lots of stuff isn't listed. "Making UI harder to use than ever" and "removing all the necessary status icons" things.... there's nothing like that in the release notes. :)