One Object Vendor 1.0

Date 2006/10/15 18:32:17 | Topic: Money

This is simple yet helpful. When touched it will tell the owner how many have been sold and how much total has been made by this vendor.

ATTENTION: There is a more new version of this script available here.

It will also IM the owner and let them know when someone buys something with the buyer's name, how much they paid and even the region they were in. So it's handy if you have multiple locations.

This will give a notecard to anyone that touches it, for more information. You can remove those two lines if you do not wish to give a note.
integer gCorrectAmount 300//enter your price

integer totalsold 0;
integer totalamount 0;

default
{
    
state_entry()
    {
        
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
        
llSetPayPrice(PAY_HIDE, [gCorrectAmountPAY_HIDEPAY_HIDEPAY_HIDE]);
    }
     
    
touch_start(integer total_number)
    {
        
llOwnerSay((string)totalsold +" units have been sold since object rez, L$" + (string)totalamount +" collected so far.");
        
llInstantMessage(llDetectedKey(0), "Fetching requested information. Select Pay to purchase."); //remove if no notecard
        
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD0)); //remove if no notecard
    

    
    
money(key idinteger amount)
    {
        if (
amount == gCorrectAmount)
        {
            
// correct amount paid
            
llInstantMessage(id"Thank you for your purchase. Please accept your product.");
            
llGiveInventory(id,llGetInventoryName(INVENTORY_OBJECT0));
            
totalsold totalsold 1;
            
totalamount amount totalsold;
            
llInstantMessage(llGetOwner(), (string)llKey2Name(id) + " has paid " +  (string)amount " in "llGetRegionName());
        }
        
        else if (
amount gCorrectAmount)
        {
            
llSay(0,"You didn't pay enough, " llKey2Name(id) + ". Refunding your payment of L$" + (string)amount ".");
            
llGiveMoney(idamount);
        }
        
        else
        {
            
integer refund amount gCorrectAmount;
            
llSay(0,"You paid too much, " llKey2Name(id) + ". Your change is L$" + (string)refund ".");
            
llGiveMoney(idrefund);
        }
    }
}




This script comes from Alicia Stella Design - Best Tip Jars in Second Life
http://www.aliciastella.com

The URL for this script is:
http://www.aliciastella.com/modules/AMS/article.php?storyid=7