Difference between revisions of "First Name Letter Prize"

From Second Life Wiki
Jump to navigation Jump to search
(New page: == 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...)
 
m (<lsl> tag to <source>)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{LSL Header}}
== First Name Letter Prize ==
== 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
I got bored one day and saw these ''lucky chairs'' and made something of my own and decided to open source it


-- UPDATE ADDED 19 DECEMBER 2009 DUE TO PEOPLE WITH LOWERCASE NAMES
    // CONVERT IT ALL INTO LOWERCASE
    firstletter  = llToLower(firstletter);
    winnerletter = llToLower(winnerletter);


== Okay, let's see the script! ==
== Okay, let's see the script! ==


Here's the basic script. I'm not the first to post this in Second Life but I can't see it in the Script Library :P.
Here's the script.
 
<source lang="lsl2">//    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", "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); 
 
    // CONVERT IT ALL INTO LOWERCASE
    firstletter  = llToLower(firstletter);
    winnerletter = llToLower(winnerletter);
            // 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());}
        }
    }
}
</source>
 
== First Name Letter Prize (Linden Version) ==


<lsl>//    First Name Prize Script for use in Second Life
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
 
<source lang="lsl2">
//    Lucky Chair Script for use in Second Life (LINDEN VERSION)
//    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)


Line 32: Line 178:
integer timerevent;
integer timerevent;
string winnerletter;
string winnerletter;
// LINDEN
integer lindens = 100;


// ENABLE DEBUG MODE 0 = NO & 1 = YES
// ENABLE DEBUG MODE 0 = NO & 1 = YES
Line 37: Line 186:


// 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", "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
Line 62: Line 211:
     // DELETE EVERYTHING AFTER LAST LETTER
     // DELETE EVERYTHING AFTER LAST LETTER
     string firstletter= llDeleteSubString(who, 1, length);   
     string firstletter= llDeleteSubString(who, 1, length);   
    // CONVERT IT ALL INTO LOWERCASE
    firstletter  = llToLower(firstletter);
    winnerletter = llToLower(winnerletter);
          
          
             // OK SO LETS SEE THEN IF THIS MATCHES
             // OK SO LETS SEE THEN IF THIS MATCHES
             if(firstletter == winnerletter)
             if(firstletter == winnerletter)
             {
             {
                 llSay(0, "We Have a Winner!!!");
                 llSay(0, "Congratulations "+who+" you just won L$"+(string)lindens);
             
   
   
                 llUnSit(whositting);
                 llUnSit(whositting);
                  
                  
                 // to give a different inventory item type,
                 // OK THIS WILL GIVE CASH TO THE WINNER
                 // replace "INVENTORY_OBJECT" with "INVENTORY_NOTECARD", etc.
                 llGiveMoney(whositting, lindens);
                llGiveInventory(whositting,llGetInventoryName(INVENTORY_OBJECT, 0));
               
                 getnewletter();
                 getnewletter();
             }
             }
Line 90: Line 244:
     // NOW LETS SAY
     // NOW LETS SAY
     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+" who will get L$"+(string)lindens);
}
}


Line 97: Line 251:
     state_entry()
     state_entry()
     {
     {
     // START BE GETTING A LETTER
     // OK LETS GET THE DEBIT PERMISSIONS
    getnewletter();
     llRequestPermissions(llGetOwner(), PERMISSION_DEBIT );  
       
    // 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);
   
     }
     }
      
      
Line 129: Line 273:
           key av = llAvatarOnSitTarget();
           key av = llAvatarOnSitTarget();
           if (av) { checkname(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>
 
</source>
 
{{LSLC|Library|First Name Letter Prize}}

Latest revision as of 20:21, 24 January 2015


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

-- UPDATE ADDED 19 DECEMBER 2009 DUE TO PEOPLE WITH LOWERCASE NAMES

   // CONVERT IT ALL INTO LOWERCASE
   firstletter  = llToLower(firstletter);
   winnerletter = llToLower(winnerletter);

Okay, let's see the script!

Here's the script.

//    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", "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);   

    // CONVERT IT ALL INTO LOWERCASE
    firstletter  = llToLower(firstletter);
    winnerletter = llToLower(winnerletter);
 
            // 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());}
        }
    }
}

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

//    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", "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);   

    // CONVERT IT ALL INTO LOWERCASE
    firstletter  = llToLower(firstletter);
    winnerletter = llToLower(winnerletter);
        
            // 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); 
        }
    }
}