12-13-2006 11:25
This script allows you to sell gifts that can be given to an individual without giving them the ability to cheat and look inside the gift prim. Also, the gifts wont even be able to be opened until 12/24

First the santa server:

CODE

key owner;
key objid;
string strid;

default
{
state_entry()
{
key objid = llGetKey();
string strid = (string)objid;
llSay(0, "Ho ho ho, Santa's UUID is " + strid);
llEmail(strid + "@lsl.secondlife.com", "Init", "Testing Reindeer"); // send email to self

llSetTimerEvent(10);
}

timer()
{
llGetNextEmail("", ""); // check for email
}

email(string time, string address, string subj, string message, integer num_left)
{

message = llDeleteSubString(message, 0, llSubStringIndex(message, "\n\n") + 1);
llGiveInventory(message, subj);


llSay(0,"Ho ho ho, sending " + subj + " to " + message);

}
}



When the prim with the santa server is rezzed, he will tell you his UUID, which you will need for all your gifts. You must also place in the santa server prim a copy of any gifts you will give.


Next the Gift:


CODE


string gift = "GIFT";
key objid= "SANTASERVERUUID"; // key of target object
integer menu_handler;
integer menu_channel;
menu(key user,string title,list buttons)//make dialog easy, pick a channel by itself and destroy it after 5 seconds
{
menu_channel = 5;
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,buttons,menu_channel);
llSetTimerEvent(20.0);
}


default
{
state_entry()
{
llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
llSetText("Touch me
to open
after Xmas!",<1,1,1>,.5);
}

touch_start(integer total_number)
{
key toucher = llDetectedKey(0);
if (toucher == llGetOwner()){

string DateToday = "";
string DateUTC = llGetDate();
integer year = (integer)llGetSubString(DateUTC, 0, 3);
integer month = (integer)llGetSubString(DateUTC, 5, 6);
integer day = (integer)llGetSubString(DateUTC, 8, 9);

if ((day >= 24) && (month == 12)) {

menu(llDetectedKey(0),"Open this Gift?",["Yes","No"]);


} else {

llSay(0,"Wait til Xmas to open me!");
llPlaySound("11db0b13-adf5-054e-1494-35d84421dd74",1);
}

} else {
llSay(0,"Huummm....maybe you should try opening your OWN presents!");
llPlaySound("289d1942-a2ea-b403-33cc-ff627a7d0f4f",1);
}

}


timer() //so the menu timeout and close its listener
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel) //in case you have others listeners
{

if(message == "Yes")

{
llSetColor(<0.75,0.0,0.0>,ALL_SIDES);
llPlaySound("3d4b63fb-1dea-d99a-fd5d-9630d3f8a2d0",1);
llSay(0,"Merry Christmas....Santa is delivering your Gift!");
llEmail((string)objid + "@lsl.secondlife.com",gift,llGetOwner());
llSetColor(<1.0,1.0,1.0>,ALL_SIDES);
llDie();
}
else if(message == "No")
{
llPlaySound("4d749cb9-58d1-7546-8b08-e79896454bca",1);

}



llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}
}}




The gift string should be the exact name of your gift. objid should be the uuid of your santa server