User:Fox Diller/GiftCardSecurity

From Second Life Wiki
< User:Fox Diller
Revision as of 07:01, 4 May 2007 by Fox Diller (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
// House of Nyla's Gift Certificate Sub_System
// 2006 by Crystal Studio
// Remember kids, go hunting with Peter Rose for a shot in the dark!

// Main Attributes to Security -- The person who this gift cert will go to FOREVA
// Who issued, and is reponsible for the issuance of the pretty cards!!
key         ISSUER_KEY      = "42047785-d5d1-49e5-b2ca-743753207934";
string      ISSUER_NAME     = "Nyla Cheeky";

// The secret passphrase to utter in a silent IM to uniquely id the card. Keep it kinda short...
string      PASSPHRASE      = "XYZ123";

// The price that this cert will be for... must just be numbers. No decimal, or nuffing...
integer     PRICE           = 2500;

// Set the nice new formated price...-- I have to declare it here if I wanna use it everywhere else...
string FORMATTED_PRICE;

// Neat function I wrote while stoned
string llNumberFormat(integer number)
{
    string output;    
    integer x;
    integer z;
    string numberString = (string)number;
    integer numberStringLength = llStringLength(numberString);
    
    if ((numberStringLength % 3) == 2) z = 1;
    else if ((numberStringLength % 3) == 0) z = 2;
    
    for(x=0;x<numberStringLength;x++)
    {
        output += llGetSubString(numberString, x, x);
        if ((x % 3) == z && x != (numberStringLength - 1))
            output += ",";
    }
    
    return output;
}

// Make the object pretty
setup()
{
    // Set the nice new formated price...
    FORMATTED_PRICE = llNumberFormat(PRICE);
    
    // Make the object's name all pretty.
    llSetObjectName("www.HouseOfNyla.com - L$"+FORMATTED_PRICE+" gift certificate");
    llSetObjectDesc("www.HouseOfNyla.com Gift Certificate System - Ohhh, someone must love you!");
 
}

// What to tell people who are not Nyla!
notOwnerSpeech()
{
    llSay(0, "Ho Ho Ho! Merry Christmas from the House of the Nyla!");
    llSay(0, "Please, have fun spending L$"+FORMATTED_PRICE+" at our exclusive boutiques!");
    llSay(0, "Remember, you must redeem this voucher with Nyla Cheeky.");
}

// MAIN()
default
{
    state_entry()
    {
        setup();
        notOwnerSpeech();
    }

    touch_start(integer total_number)
    {
        if (llDetectedName(0) == ISSUER_NAME && llDetectedKey(0) == ISSUER_KEY)
            if (llGetOwner() == ISSUER_KEY)
                llInstantMessage(ISSUER_KEY, "Hi, this is my passphrase { "+PASSPHRASE+" } and my official price is + { L$"+FORMATTED_PRICE+" }");
            else
            {
                notOwnerSpeech();
                llInstantMessage(ISSUER_KEY, "Remember! You must ask for for the user to send you this cert to get the passphrase inside...");
            }
        else
            notOwnerSpeech();
    }
    
    on_rez(integer stater)
    {
        llResetScript();
    }
}