Put in object with 2 products and info note & set price. Owner can check to see total earned.
Put this script along with TWO OBJECTS and an optional information Notecard.
Users will get a notecard on Touch and get item when a 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 price = 100; //price for single (first item)
integer copyprice = 400; //price for copyable (second item)
string single = "Full Object Name"; //must match exact item name
string copyable = "Copyable Full Object Name"; //must match exact item name
string thanks = "Thank you for your purchase. Please accept your product.";
// End variables
//--------------------------------------------
integer totalsold = 0;
integer totalsoldcopy = 0;
integer totalamount = 0;
integer totalamountcopy = 0;
string startdate;
string ts;
list now;
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [price, copyprice, 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)price + " for '" + single + "' or L$" + (string)copyprice + " for '" + copyable + ".'");
if (llGetInventoryNumber(INVENTORY_NOTECARD) > 0) //notecard available
{
llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}
else if ( llDetectedKey(0) == llGetOwner() ) //object owner
{
llOwnerSay((string)totalsold +" Single units have been sold, L$" + (string)totalamount +" since " + startdate + ".");
llOwnerSay((string)totalsoldcopy +" Copyable units have been sold, L$" + (string)totalamountcopy +" since " + startdate + ".");
integer alltotal = totalamount + totalamountcopy;
llOwnerSay("L$" + (string)alltotal +" collected total so far.");
}
}
money(key id, integer amount)
{
if (amount == price) // single amount paid
{
llInstantMessage(id, thanks);
llGiveInventory(id, single); //single version
totalsold = totalsold + 1;
totalamount = amount * totalsold;
llInstantMessage(llGetOwner(), (string)llKey2Name(id) + " has paid " + (string)amount + " in "+ llGetRegionName());
}
else if (amount == copyprice) // copyable amount paid
{
llInstantMessage(id, thanks);
llGiveInventory(id, copyable); //copyable version
totalsoldcopy = totalsoldcopy + 1;
totalamountcopy = amount * totalsoldcopy;
llInstantMessage(llGetOwner(), (string)llKey2Name(id) + " has paid " + (string)amount + " in "+ llGetRegionName());
}
else // Not a correct amount, Refund amount
{
llInstantMessage(id, "Sorry that is not the correct amount. Refunding you L$" + (string)amount + ".");
llGiveMoney(id, amount);
}
}
}