CODE
//Most of script written by an unknown author.
//Support for email notifications and configuration options for chosing to
//enable or disable hover text and choose notifications by IM or Email by Validus Bishop.
string object_name = "ExItem01"; //This is the name of the object you are selling and MUST BE EXACTLY THE SAME NAME AS THAT YOU ARE WANTING TO SELL.
string store_name = "Main Store"; //Name of location item sold from.
integer Hover = 0; //0=No, 1=Yes for hovertext
string Hname = "Example Item 1";//This will be your object name used in the hovertext
string Hdes = "Rocking example item!"; //This is your object description
vector color = <1,1,0>; //This is the color of the hover text
integer price = 50; //This is the price of your item
integer Notifications = 1; //0=IM, 1=Email
string Email = "user@domain.com"; //The email address you want notifications sent to if enabled.
string Ttext = "This is my example item, it costs L$50!"; //This is the touch text what people will see if they left click your vendor.
default
{
state_entry()
{
//Request permissions to debit owner's account.
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
run_time_permissions(integer perms)
{
if(perms & PERMISSION_DEBIT)
{//Permissions have been granted so proceed.
//Set the hover text, USing the above predifind variables.
if(Hover < 1)
{
llSetText("", <0,0,0>, 1.0);
}
else
{
llSetText(Hname + "\n" + Hdes + "\nL$" + (string) price + "\n", color, 1);
}
}
else
{//Permissions was denied.
//Because permissions was denied we shall change state to give the owner a chance of resetting permissions.
state idol;
}
}
touch_start(integer total_number)
{
//When touched will say the text previously defined in the variables.
llSay(0, Ttext);
}
money(key customer, integer amount)
{
if(amount > price)
{ //if amount payed is more than price, refund the diffrence and give object.
llGiveInventory(customer, object_name);
llInstantMessage(customer, "Thank you for your purchase although you did over pay. You will be refunded the diffrence in a moment.");
llGiveMoney(customer, amount - price);
//Notification
if (Notifications < 1)
{
llInstantMessage(llGetOwner(), llKey2Name(customer) + " has just purchased " + object_name + " from " + llGetRegionName() + ". ");
}
else
//Email notifcation #1
{
llEmail((string)Email, "Sale to " + llKey2Name(customer) + " at " + store_name + ".", llKey2Name(customer) + " has just purchased " + object_name + " for L$" + (string) price + " from " + store_name + " in " + llGetRegionName() + ". ");
}
}
else if(amount < price)
{//If the amount is less than the price then give back all the money and explain why...
llGiveMoney(customer, amount);
llInstantMessage(customer, "I am sorry, You never paid the correct amount of L$" + (string) price + ", Your money has been refunded.");
}
else
{//The only option left is if they pay the correct amount.
//Give object and say Thank you.
llGiveInventory(customer, object_name);
llInstantMessage(customer, "Thank you for your purchase.");
//Notification
if (Notifications < 1)
{
llInstantMessage(llGetOwner(), llKey2Name(customer) + " has just purchased " + object_name + " from " + llGetRegionName() + ". ");
}
else
//Email notification #2
{
llEmail((string)Email, "Sale to " + llKey2Name(customer) + " at " + store_name + ".", llKey2Name(customer) + " has just purchased " + object_name + " for L$" + (string) price + " from " + store_name + " in " + llGetRegionName() + ". ");
}
}
}
on_rez(integer start_param)
{// if the vendor is picked up and replaced then reset the script
llResetScript();
}
}
state idol
{//Permission was denied.
state_entry()
{
//Give instructions to owner on how they can give the permissions again
llInstantMessage(llGetOwner(), "You have chosen not to give permissions, This vendor will now sit in an idle state.");
llInstantMessage(llGetOwner(), "If you wish to give your permission for this vendor to work accordingly, please left click the vendor.");
//Set text informing customers the vendor is not configured.
llSetText("VENDOR IS OUT OF ORDER\nIf you wish to see\nthis merchants wares\nplease contact the vendors owner.\n", <1,0,0>,1);
}
touch_start(integer total_num)
{
if(llDetectedKey(0) == llGetOwner())
{//Touched by the owner
//Reset Script to obtain permission request
llResetScript();
}
else
{//Touched by someone other than the owner
//Give instructions on how they can see owners line of products
llSay(0, "We are sorry but this vendor is currently out of order.");
llSay(0, "If you wish to see this merchants wares then please contact the owner.");
}
}
on_rez(integer start_param)
{// if the vendor is picked up and replaced then reset the script
llResetScript();
}
}
Thanks,
Val