This is the Server side script.
//Santa_server.lsl v0.2a
//by Jora Welesa.
//This script is free to copy, transfer, or modify, but in no way, shape, or form may it be sold without
//the express concent of the creator.
//This is the server side script used to handle taking requests from the various
//gift cards that end up in SL for the vendor's items.
//GLOBAL VARIABLES -- Edit these to suit.
string Password = ""; //This is a password to verify integrity of the gift card and
//make sure no one's emulating it.
string rwEmail = ""; //E-mail address to send reports to if someone tries to emmulate the gift card.
//Change nothing below this line!!
integer giftCounter; //Counter for how many gifts have been given out.
list fData; //List to hold Formated data for request handling.
key giftGetter; //Key of the person getting the dift.
string request; //Type of incoming request.
string passMatch; //String to hold the password match.
string gift;
default
{
state_entry()
{
llOwnerSay(llGetObjectName() + " Ready."); //Let the owner know we're good to go.
llSetTimerEvent(2.5);
}
on_rez(integer param)
{
llResetScript();
}
timer()
{
llGetNextEmail("",""); //Check the queue for incoming e-mails to the server.
}
touch_start(integer num)
{
if(llDetectedKey(0) == llGetOwner())
{
llOwnerSay("Server key is: " + (string)llGetKey());
}
}
email(string time, string address, string subj, string message, integer num_left)
{
//Convert the subject line into a list of commands.
fData = llParseStringKeepNulls(subj,["*_*"],[]);
request = llList2String(fData,0); //Get our request from the client card.
passMatch = llList2String(fData,1);
giftGetter = (key)llList2String(fData,2);
gift = llList2String(fData,3);
if(request == "CHECK")
{
llInstantMessage(giftGetter,llGetObjectName() + " is taking requests.");
return;
}
if(request == "GIFT")
{
//The client wants their gift.
//First thing is verify the password.
if(passMatch == Password)
{
//Password good. Let's go.
llInstantMessage(giftGetter,"Verified. Please Stand by....");
llGiveInventory(giftGetter,gift);
llInstantMessage(giftGetter,"Merry Christmas! ");
giftCounter++;
llSetText(llGetObjectName() + " has served \n " + (string)giftCounter + " gifts!",<1,1,1>,1);
}
else
{
//Password not good!
llInstantMessage(giftGetter,"The gift card you are using is not verified. Contacting creator.");
llRequestAgentData(giftGetter,DATA_NAME);
}
//Cleanup.
fData = []; //Clear the data list to conserve memory.
return;
}
}
dataserver(key queryID,string data)
{
llEmail(rwEmail,"Failed Gift Report.",data + " attempted to get " + gift + ". However the password was invalid.");
}
}
To set this up, Create an object and name it accordingly, then copy this script into it.
Edit the value for the variable
Password to an alphanumeric password. Something easy for you to remember, but would be difficult to guess.
Edit the value for the variable
email to your RW e-mail address. Someplace you can easily get to in order to recieve reports.
Once the script is compiled and running, touch the server to get it to report its key to you. Save this key as you will need it in a moment.
Now, stuff the server with all the inventory that you wish to put up to be purchased as gifts.
Here is the code for the gift cards.
//Gift_card.lsl v0.1a
//by Jora Welesa.
//This script is free to copy, transfer, or modify, but in no way, shape, or form may it be sold without
//the express concent of the creator.
//This is the client side of the Santa_server set.
//When rezzed in world, the owner only need type "/redeem" to recieve their gift.
//It comes with layered security to help prevent theft and ensure
//validity of the gift requests.
//GLOBAL VARIABLES--Edit these to suit.
string Password = ""; //Should be the same password as is on the server.
key serverKey = "";//Key to the server. Get this by touching the server while it's running.
string creatorName = ""; //Your Complete Case Sensitive SL av name.
string floatyMessage = "";//Message to be shown floating above the gift card when rezzed.
//Change nothing below this line!!
string gift;
vector color;
default
{
on_rez(integer param)
{
llOwnerSay("Starting up.");
//Security check#1. Is the script still within an object made by you?
llRequestAgentData(llGetCreator(),DATA_NAME);
}
dataserver(key queryid, string data)
{
if(data != creatorName)//Script and prim have different creators!
{
llOwnerSay("You have put this into an object it is not intended to be in! ");
llOwnerSay("Santa Says you been bad!");
llRemoveInventory(llGetScriptName());
}
else //Pass security check #1.
{
//Security Check #2. Has it already been used?
color = llGetColor(ALL_SIDES);
if(color != <1,0,0>)
{
//Pass Security Check #2. Not used previously.
gift = llGetObjectDesc(); //Get the gift name to send to the server.
llListen(0,"",llGetOwner(),"");
llSetText(floatyMessage + " \n Type '/Check' to check server status. \n Type '/Redeem' to receive your gift.",<1,1,1>,1);
return;
}
else
{
//Someone's used this card already!
llOwnerSay("This gift card has already been used and must be recycled.");
llDie();
}
}
}
listen(integer channel,string name,key id,string msg)
{
if(llToLower(msg) == "/check")
{
llOwnerSay("Checking server status. Please Stand by...");
llEmail((string)serverKey + "@lsl.secondlife.com",
"CHECK*_*" + Password + "*_*" + (string)llGetOwner() + "*_*" + gift,
"");
llOwnerSay("Polling Complete.");
return;
}
if(llToLower(msg) == "/redeem")
{
llOwnerSay("Contacting Server to get your gift. Please wait.");
llSetColor(<1,0,0>,ALL_SIDES);
//Security Check #3. Server Side Password Verify!
llEmail((string)serverKey + "@lsl.secondlife.com",
"GIFT*_*" + Password + "*_*" + (string)llGetOwner() + "*_*" + gift,
"");
llOwnerSay("Thank you and have a happy holiday! ");
llOwnerSay("Cleaning up.");
llDie();
}
}
}
To set this up, create a single small prim, preferably a box shaped into the form of a card. Set whatever texture you would like on, then set the color. It's important that the color
NOT be red as this is a security check.
Set the value for the Variable
Password to the same as that for the server.
Set the value for the variable
serverkey to the key of the server, which you should've gotten when you set the server up.

Put your complete case sensitive SL avatar name into the variable for
creatorName.
Finally change the value of
floatyMessage to the text you want displayed above the card when it's rezzed in world.
To define what gift this is for, just put the
exact name of the item this is for into the description of the object.
That's it. Now it will communicate with the server and the server will take the item from its inventory and hand it to the person that redeemed the card.
EDIT
Ok. Just got home and verified the script. It seems to work as expected, which is a blessing.

I tried to keep this as secure as possible while still have it open source. So even with an emulator, without the password someone would have a hard time breaking into your server.
I'm in the process of building up and boxing a freebie version in world so that'll be up for grabs shortly.
