Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Single Item Vendor w/ IM & Email Support

Validus Bishop
Registered User
Join date: 24 Feb 2006
Posts: 81
07-13-2006 09:21
I had this script and it had no author or permissions guidelines on it. It supported IM notifications via uncommenting lines in the script, but I wanted to easily set IM or Email (which it didn't support at all) and I wanted an option to disable the hover text... so, here you all are. Unless the original author steps forward and requests otherwise, I don't care what anyone does with this, heh.

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
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
07-19-2006 07:50
/54/eb/123364/1.html
_____________________
i've got nothing. ;)
Burnman Bedlam
Business Person
Join date: 28 Jan 2006
Posts: 1,080
07-19-2006 13:22
From: Nada Epoch
Since we are not sure of the origins of this script, I am going to wait 5 days before creating the discussion thread so that it is easy enough to clean up if the original owner chooses not to share.

Feel free to discuss here until the discussion thread gets created.


Not knowing the authorship of something certainly does not place it into public domain.
_____________________
Burnman Bedlam
http://theburnman.com


Not happy about Linden Labs purchase of XStreet (formerly SLX) and OnRez. Will this mean LL will ban resident run online shoping outlets in favor of their own?
Dragon Eccleston
Registered User
Join date: 25 Dec 2005
Posts: 42
07-19-2006 23:01
Dragon's rules for any script that uses llGiveMoney()

Needs 3 states, get permission in default, if they grant permissions then go to the state with the money statement, if not go to an error state (possibly with a way to switch back to the good money state).

A change event in the good money state to detect a change in owner and call for a script reset to get permissions again.

Check llGetPermissions() before any llGiveMoney call to make sure one last time that you still have permissions if not do a DB lookup for the owners name and inform whoever was supposed to get the money who to complain to.
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
07-20-2006 06:52
From: Burnman Bedlam
Not knowing the authorship of something certainly does not place it into public domain.

True. I put a line into the lindens to find out how they want it handled.
_____________________
i've got nothing. ;)
Burnman Bedlam
Business Person
Join date: 28 Jan 2006
Posts: 1,080
07-20-2006 06:54
From: Nada Epoch
True. I put a line into the lindens to find out how they want it handled.


Sorry if that sounded grumpy Nada... I didn't mean to sound so *blech* about it... lol
_____________________
Burnman Bedlam
http://theburnman.com


Not happy about Linden Labs purchase of XStreet (formerly SLX) and OnRez. Will this mean LL will ban resident run online shoping outlets in favor of their own?
Wirimu Dale
Registered User
Join date: 7 Jun 2006
Posts: 4
Thank you!
10-15-2006 02:16
Hi Val,

Thats what I have been looking for....you need this to sell any RL items inlife!....otherwise it is all geared to being able to sell instant copies of the products you have for sale.

Thank you

Wirimu