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, [gCorrectAmount, PAY_HIDE, PAY_HIDE, PAY_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_NOTECARD, 0)); //remove if no notecard
}
money(key id, integer amount)
{
if (amount == gCorrectAmount)
{
// correct amount paid
llInstantMessage(id, "Thank you for your purchase. Please accept your product.");
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);
}
}
}
|