Difference between revisions of "First Name Letter Prize"

From Second Life Wiki
Jump to navigation Jump to search
Line 13: Line 13:
<lsl>//    First Name Prize Script for use in Second Life
<lsl>//    First Name Prize Script for use in Second Life
//    Copyright (C) 2009  RaithSphere Whybrow (Second Life Avatar Name)/Gavin Owen (Real Name)
//    Copyright (C) 2009  RaithSphere Whybrow (Second Life Avatar Name)/Gavin Owen (Real Name)
 
//    This program is free software: you can redistribute it and/or modify
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//    (at your option) any later version.
 
//    This program is distributed in the hope that it will be useful,
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//    GNU General Public License for more details.
 
//    You should have received a copy of the GNU General Public License
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
// CONFIG \\
// CONFIG \\
 
// How Often do we change Letter?
// How Often do we change Letter?
// THIS IS IN MINUITES
// THIS IS IN MINUITES
Line 35: Line 35:
integer timerevent;
integer timerevent;
string winnerletter;
string winnerletter;
 
// ENABLE DEBUG MODE 0 = NO & 1 = YES
// ENABLE DEBUG MODE 0 = NO & 1 = YES
integer debug = 0;
integer debug = 0;
 
// LETS GET TEH ALPHABET!
// LETS GET TEH ALPHABET!
list letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "I", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
list letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "I", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
 
// DEBUG SHIT DON'T MESS WITH THIS
// DEBUG SHIT DON'T MESS WITH THIS
deBug(string dmsg)
deBug(string dmsg)
Line 48: Line 48:
     llOwnerSay(dmsg);
     llOwnerSay(dmsg);
}
}
 
 
// THIS IS THE CHECK NAME SUB
// THIS IS THE CHECK NAME SUB
checkname(key whositting)
checkname(key whositting)
Line 65: Line 65:
     // DELETE EVERYTHING AFTER LAST LETTER
     // DELETE EVERYTHING AFTER LAST LETTER
     string firstletter= llDeleteSubString(who, 1, length);   
     string firstletter= llDeleteSubString(who, 1, length);   
       
             // OK SO LETS SEE THEN IF THIS MATCHES
             // OK SO LETS SEE THEN IF THIS MATCHES
             if(firstletter == winnerletter)
             if(firstletter == winnerletter)
Line 71: Line 71:
                 llSay(0, "We Have a Winner!!!");
                 llSay(0, "We Have a Winner!!!");
                 llUnSit(whositting);
                 llUnSit(whositting);
               
                 // to give a different inventory item type,
                 // to give a different inventory item type,
                 // replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
                 // replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
                 llGiveInventory(whositting,llGetInventoryName(INVENTORY_OBJECT, 0));
                 llGiveInventory(whositting,llGetInventoryName(INVENTORY_OBJECT, 0));
               
                 getnewletter();
                 getnewletter();
             }
             }
Line 85: Line 85:
             }     
             }     
}
}
 
// SUB TO GET A NEW LETTER
// SUB TO GET A NEW LETTER
getnewletter()
getnewletter()
Line 94: Line 94:
     winnerletter = llList2String(shuffled, 0);
     winnerletter = llList2String(shuffled, 0);
     llShout(0, "We are now looking for a lucky winner who's firstname starts with "+winnerletter);
     llShout(0, "We are now looking for a lucky winner who's firstname starts with "+winnerletter);
    llSetText("Current letter is "+winnerletter, <1,1,1>, 1);
}
}
 
default
default
{
{
Line 102: Line 103:
     // START BE GETTING A LETTER
     // START BE GETTING A LETTER
     getnewletter();
     getnewletter();
       
     // THIS CONVERTS THE MINUITES INTO SECONDS WHICH IS WHAT LSL LIKES FOR TIMERS
     // THIS CONVERTS THE MINUITES INTO SECONDS WHICH IS WHAT LSL LIKES FOR TIMERS
     timerevent = (changeletter * 60);
     timerevent = (changeletter * 60);
   
     // START THE TIMER EVENT
     // START THE TIMER EVENT
     llSetTimerEvent(timerevent);
     llSetTimerEvent(timerevent);
   
     // MAKE A SIT TARGET
     // MAKE A SIT TARGET
     llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
     llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);
   
     }
     }
   
     timer()
     timer()
     {
     {
Line 119: Line 120:
         getnewletter();
         getnewletter();
     }
     }
   
     changed(integer change)
     changed(integer change)
     {
     {

Revision as of 22:42, 6 October 2009


First Name Letter Prize

I got bored one day and saw these lucky chairs and made something of my own and decided to open source it


Okay, let's see the script!

Here's the script.

<lsl>// First Name Prize Script for use in Second Life // Copyright (C) 2009 RaithSphere Whybrow (Second Life Avatar Name)/Gavin Owen (Real Name)

// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.

// This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.

// You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>.

// CONFIG \\

// How Often do we change Letter? // THIS IS IN MINUITES // SO SIMPLE MATHS integer changeletter = 10; integer timerevent; string winnerletter;

// ENABLE DEBUG MODE 0 = NO & 1 = YES integer debug = 0;

// LETS GET TEH ALPHABET! list letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "I", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];

// DEBUG SHIT DON'T MESS WITH THIS deBug(string dmsg) {

   if(debug)
   llOwnerSay(dmsg);

}


// THIS IS THE CHECK NAME SUB checkname(key whositting) {

   // SAYS THE AVATARS KEY IN DEBUG MESSAGE
   deBug((string)whositting);
   // WE NEED TO KNOW WHO IS SITTING HERE A KEY IS USELESS!
   string whothat = llKey2Name(whositting);
   // SPLIT THER NAME UP 
   list name  = llParseString2List(whothat, [" "], []);
   // 0 is the First name change to 1 if you want to use LASTNAME
   string who = llList2String(name, 0);
   // Get the Length of the name
   integer length = llStringLength(who);
   // DELETE EVERYTHING AFTER LAST LETTER
   string firstletter= llDeleteSubString(who, 1, length);   

           // OK SO LETS SEE THEN IF THIS MATCHES
            if(firstletter == winnerletter)
            {
                llSay(0, "We Have a Winner!!!");
                llUnSit(whositting);

               // to give a different inventory item type,
               // replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
                llGiveInventory(whositting,llGetInventoryName(INVENTORY_OBJECT, 0));

                getnewletter();
            }
            // NOPE THEY LOSE!!
            else
            {
                llSay(0, "Your first name doesn't begin with the letter "+winnerletter+ " it's "+firstletter);      
                llUnSit(whositting);             
           }     

}

// SUB TO GET A NEW LETTER getnewletter() {

   // LETS SHUFFLE THE LIST AND GET A LETTER!
   list shuffled = llListRandomize(letters, 1);
   // NOW LETS SAY
   winnerletter = llList2String(shuffled, 0);
   llShout(0, "We are now looking for a lucky winner who's firstname starts with "+winnerletter);
   llSetText("Current letter is "+winnerletter, <1,1,1>, 1);

}

default {

   state_entry()
   {
    // START BE GETTING A LETTER
    getnewletter();

    // THIS CONVERTS THE MINUITES INTO SECONDS WHICH IS WHAT LSL LIKES FOR TIMERS
    timerevent = (changeletter * 60);

    // START THE TIMER EVENT
    llSetTimerEvent(timerevent);

    // MAKE A SIT TARGET
    llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);

   }

   timer()
   {
       // TIMER HAS RUN GET A NEW LETTER!!
       getnewletter();
   }

   changed(integer change)
   {
       if (change & CHANGED_INVENTORY)         
       {
           // YOU CHANGED THE SCRIPT OR SOMETHING IN HERE
           // RESET THE SCRIPT
           llResetScript();
       }
       if (change & CHANGED_LINK) 
       {
         key av = llAvatarOnSitTarget();
         if (av) { checkname(llAvatarOnSitTarget());}
       }
   }

} </lsl>

First Name Letter Prize (Linden Version)

After being contacted by Zoom Blitz i changed this now so there is also a linden giving version

As with most scripts involving money i advise you get a few people you trust or a few alts to test this out

<lsl> // Lucky Chair Script for use in Second Life (LINDEN VERSION) // Copyright (C) 2009 RaithSphere Whybrow (Second Life Avatar Name)/Gavin Owen (Real Name)

// This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version.

// This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details.

// You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>.

// CONFIG \\

// How Often do we change Letter? // THIS IS IN MINUITES // SO SIMPLE MATHS integer changeletter = 10; integer timerevent; string winnerletter;

// LINDEN integer lindens = 100;

// ENABLE DEBUG MODE 0 = NO & 1 = YES integer debug = 0;

// LETS GET TEH ALPHABET! list letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "I", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];

// DEBUG SHIT DON'T MESS WITH THIS deBug(string dmsg) {

   if(debug)
   llOwnerSay(dmsg);

}


// THIS IS THE CHECK NAME SUB checkname(key whositting) {

   // SAYS THE AVATARS KEY IN DEBUG MESSAGE
   deBug((string)whositting);
   // WE NEED TO KNOW WHO IS SITTING HERE A KEY IS USELESS!
   string whothat = llKey2Name(whositting);
   // SPLIT THER NAME UP 
   list name  = llParseString2List(whothat, [" "], []);
   // 0 is the First name change to 1 if you want to use LASTNAME
   string who = llList2String(name, 0);
   // Get the Length of the name
   integer length = llStringLength(who);
   // DELETE EVERYTHING AFTER LAST LETTER
   string firstletter= llDeleteSubString(who, 1, length);   
       
           // OK SO LETS SEE THEN IF THIS MATCHES
            if(firstletter == winnerletter)
            {
                llSay(0, "Congratulations "+who+" you just won L$"+(string)lindens);
             
   
   
                llUnSit(whositting);
               
               // OK THIS WILL GIVE CASH TO THE WINNER
               llGiveMoney(whositting, lindens);
                getnewletter();
            }
            // NOPE THEY LOSE!!
            else
            {
                llSay(0, "Your first name doesn't begin with the letter "+winnerletter+ " it's "+firstletter);      
                llUnSit(whositting);             
           }     

}

// SUB TO GET A NEW LETTER getnewletter() {

   // LETS SHUFFLE THE LIST AND GET A LETTER!
   list shuffled = llListRandomize(letters, 1);
   // NOW LETS SAY
   winnerletter = llList2String(shuffled, 0);
   llShout(0, "We are now looking for a lucky winner who's firstname starts with "+winnerletter+" who will get L$"+(string)lindens);

}

default {

   state_entry()
   {
    // OK LETS GET THE DEBIT PERMISSIONS
    llRequestPermissions(llGetOwner(), PERMISSION_DEBIT );   
   }
   
   timer()
   {
       // TIMER HAS RUN GET A NEW LETTER!!
       getnewletter();
   }
   
   changed(integer change)
   {
       if (change & CHANGED_INVENTORY)         
       {
           // YOU CHANGED THE SCRIPT OR SOMETHING IN HERE
           // RESET THE SCRIPT
           llResetScript();
       }
       if (change & CHANGED_LINK) 
       {
         key av = llAvatarOnSitTarget();
         if (av) { checkname(llAvatarOnSitTarget());}
       }
   }
   // OK CHECKING RUNTIME PERMISSIONS
   run_time_permissions (integer perm)
   {
       // OK WE GRANTED IT DEBIT RIGHTS
       if(perm & PERMISSION_DEBIT)
       {
          // START BE GETTING A LETTER
          getnewletter();
       
          // THIS CONVERTS THE MINUITES INTO SECONDS WHICH IS WHAT LSL LIKES FOR TIMERS
          timerevent = (changeletter * 60);
    
    // START THE TIMER EVENT
    llSetTimerEvent(timerevent);
    
    // MAKE A SIT TARGET
    llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION); 
       }
   }

}

</lsl>