One Object Vendor 2.0

Written by Kitsune

Put in object with product and info note & set price. Owner can check to see total earned. 

Put this script along with ONE OBJECT and an optional information Notecard. If multiple items, put them into one "box" object.

Users will get a notecard on Touch and get item when correct amount is paid.

Owner will get IM for each sale with user's name and can Touch to see how much money earned at any time.

 

 

 

// Begin variables
integer gCorrectAmount = 300; //enter your price
string thanks = "Thank you for your purchase. Please accept your product.";
// End variables
//--------------------------------------------

integer totalsold = 0;
integer totalamount = 0;

string startdate;
string ts;
list now;

default
{
    on_rez( integer param )
    {
        llResetScript();
    }
    
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
        llSetPayPrice(PAY_HIDE, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        
        ts = llGetDate();
        now = llParseString2List( ts, ["-"], [] ) ;
        integer nyear = (integer)llList2String( now, 0 ) ;   
        integer nmonth = (integer)llList2String( now, 1 ) ;
        integer nday = (integer)llList2String( now, 2 ) ;
        if (nmonth == 1)
        {
            string smonth = "January";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 2)
        {
            string smonth = "February";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 3)
        {
            string smonth = "March";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 4)
        {
            string smonth = "April";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 5)
        {
            string smonth = "May";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 6)
        {
            string smonth = "June";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 7)
        {
            string smonth = "July";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 8)
        {
            string smonth = "August";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 9)
        {
            string smonth = "September";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 10)
        {
            string smonth = "October";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 11)
        {
            string smonth = "November";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
        else if  (nmonth == 12)
        {
            string smonth = "December";
            startdate = smonth + " " + (string)nday + ", " + (string)nyear;
        }
    }
     
    touch_start(integer total_number)
    {
        if ( llDetectedKey(0) != llGetOwner() )
        {
            llInstantMessage(llDetectedKey(0), "Pay this object L$" + (string)gCorrectAmount + " to purchase.");
            if (llGetInventoryNumber(INVENTORY_NOTECARD) > 0) //notecard available
            {
                llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));
            }
        }
        else if ( llDetectedKey(0) == llGetOwner() )//object owner
        {
            llOwnerSay((string)totalsold +" units have been sold, L$" + (string)totalamount +" since " + startdate + ".");
        }
    } 
    
    money(key id, integer amount)
    {
        if (amount == gCorrectAmount)
        {
            // correct amount paid
            llInstantMessage(id, thanks);
            llGiveInventory(id,llGetInventoryName(INVENTORY_OBJECT, 0));
            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(id, amount);
        }
        
        else
        {
            integer refund = amount - gCorrectAmount;
            llSay(0,"You paid too much, " + llKey2Name(id) + ". Your change is L$" + (string)refund + ".");
            llGiveMoney(id, refund);
        }
    }
}