Random Object Giver Script

/We're saving the keys to be sure people can only touch once. 
//To avoid running out of memory, the list must be cleared occassionally or at least trimmed. 
//This is accomplished, in this script, by resetting after set period of time


integer reset_list=86400;//reset list after one day (in seconds)
list touched;
default{
touch_start(integer total_number){
key id = llDetectedKey(0);
if(llListFindList(touched,[id])==-1){
touched+=[id];
llGiveInventory(id,llGetInventoryName(INVENTORY_OBJECT,(integer)llFrand(llGetInventoryNumber(INVENTORY_OBJECT))));
}
if(llGetTime()>=reset_list){llResetScript();}//clear list | restart script time 
}
}

 

Gummi Gumball Machine

Found on the Second Life Scripting Library:

// example gummy gumball machine
// version 0.3
// Public Domain January 2015 irihapeti
//
// will give out all the gummys in the machine contents
// in some "random" order and then refill itself
// so that a player wont get 2 gummmys the same in a row
// and if they keep playing will get all the common gummys in
// best case: not less than gbM-1 turns [exactly 1 of each common
//  gummmy] and worst case: not greater than 2*gbM-3 turns
//
// for rares
//   if gbC = 3 and gbM = 5 (which incl. the rare) then rare is
//   guarantee to be given 1 in each set of 13. 3 * 4 + 1
//   altho from a players pov they more likely to play bc can get at
//   least 1 of each common in max 7 turns. 3 + 4 
//   if gbC = 4 and gbM = 5 then is still 7 for the commons. and now
//    4 * 4 + 1 = 17 for rare
//   the shortest period for rare is: 2
//   the longest period is: 1 + (gbM-1) * gbC * gbC
//   e.g: if gbM = 4 and gbC = 2 then 3 * 2 * 2 + 1 = 13 
//         | x123 123 | 123 123x |  where x = rare
//   gbM = 3. gbC = 2. 2 * 2 * 2 + 1 = 9
//         | x12 12 | 12 12x |
         
// usage: reset script after loading the gummys in machine
//        give permission for refunds
//        then just pay to play
 
// change these to whichever
integer gbP = 1;      // L$ price to play gummy gumball
integer gbC = 3;      // number of rounds in which 1 only rare will be given
string  gbN = "rare"; // name of the rare gummy
 
// internals
list    gbL;  // index list of gummys currently in play
list    gbW;  // listcopy of gummys in machine excluding rare
integer gbG;  // this gummy to give
integer gbI;  // indice of this gummy to give
integer gbJ;  // indice of this round
integer gbK;  // indice of rare round
integer gbM;  // total number of gummys in machine
integer gbQ;  // number of gummys for this round
integer gbR;  // indice of the rare gummy
key     gbY;  // key of last player

gbS() // shuffle n pick
{
    if ((++gbI) == gbQ)  // then shuffle
    { 
        if ((++gbJ) == gbC) // rounds exhausted so pick new rare round
        {
            gbK = (integer)llFrand(gbC);
            gbJ = 0;    
        }             

        integer n = llList2Integer(gbL, gbQ-1); // save last item of old list
        
	gbL = gbW;                              // get copy of commons
        if (gbJ == gbK) gbL += [gbR];           // add in rare if rare round  
        gbL = llListRandomize(gbL, 1);          // shuffle
        
	gbQ = llGetListLength(gbL);             // save length of new list
        integer m = llList2Integer(gbL, 0);     // get 1st item of new list    

        if (n == m)  // 1st of new list is same as last of old list so swap it to a later place
        {
            n = 1 + (integer)llFrand(gbQ - 1);
            gbL = [llList2Integer(gbL, n)] + llDeleteSubList(llListReplaceList(gbL, [m], n, n), 0, 0);
        }
        
	gbI = 0;  // reset the list index
    }
    
    // next gummy in list
    gbG = llList2Integer(gbL, gbI);
}

gbA()  // reset machine
{
   gbL = gbW;
   gbQ = gbM;
   gbI = gbQ-1;
   gbJ = gbC-1;    
   gbS();
}    

default
{
   state_entry()
   {
      // set machine

      gbM = llGetInventoryNumber(INVENTORY_OBJECT);
      if (gbM == 0)
      {
         llOwnerSay("is no gummys in machine");
         return;
      }

      // get gummys into list. mark the rare
      gbR = -1;
      gbW = [];
      integer i;
      for (i = 0; i  0)
        { 
	   llGiveMoney(id, amount);
           llWhisper(0, "eep! you paid the wrong amount. "
              + "so we refund your L$" + (string)amount + " ok");
	}
        // if amount <0 then is a serious SL serverside error like totally

        return;
      }

      // clocker defend. reset everytime is a new player
      if (id != gbY)
      {
         gbY = id;
         gbA();
      }
          
      // all good. so give gummy     
      llGiveInventory(id, llGetInventoryName(INVENTORY_OBJECT, gbG));
                
      if (gbG == gbR)  // then rare given. add bling here as you like
      {
         llWhisper(0, "woohoo! you got a rare gummy \\o/");
      }
      else // common given
      {
         llWhisper(0, "enjoy your gummy ok (:");
      }

      gbS();  // prep for next play
   }
}  

 

Texture Vendor

You will need at least 3 prims for this project This script goes in the root prim:

integer price = 5; // price
float time = 0; // Enter a value if you want to auto scroll

string vendorname;
integer total;
integer counter;
integer change;

next()
{
    total=llGetInventoryNumber(INVENTORY_TEXTURE);
    vendorname = llGetObjectName();
    counter++;
    if(counter>=total)
    {
        counter=0;
    }
    llSetTexture(llGetInventoryName(INVENTORY_TEXTURE,    counter),ALL_SIDES);
    if (price > 0)
    {
        llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE,  counter) + "\n L$" + (string)price + "\n", <1 ,1,1>, 1);
    }
    else
    {
        llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE,  counter) + "\n Touch to recieve \n", <1 ,1,1>, 1);
    }
    llTriggerSound("Pressed", 1);
}
prev()
{
    total=llGetInventoryNumber(INVENTORY_TEXTURE);
    vendorname = llGetObjectName();
    if (counter > 0)
    {
        counter--;
    }
    else
    {
        counter=total - 1;
    }
    llSetTexture(llGetInventoryName(INVENTORY_TEXTURE,    counter),ALL_SIDES);
    if (price > 0)
    {
        llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE,  counter) + "\n L$" + (string)price + "\n", <1 ,1,1>, 1);
    }
    else
    {
        llSetText(vendorname + "\n" + llGetInventoryName(INVENTORY_TEXTURE,  counter) + "\n Touch to recieve \n", <1 ,1,1>, 1);
    }
    llTriggerSound("Pressed", 1);
}

default
{
    state_entry()
    {
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT  );
        next();
        llSetTimerEvent(time);
    }
    touch_start(integer total_number)
    {
        if ( llGetLinkName(llDetectedLinkNumber(0)) == "next" )
        {
            next();
        }
        else if ( llGetLinkName(llDetectedLinkNumber(0)) == "prev" )
        {
            prev();
        }
        else
        {
            if (price > 0)
            {
                llWhisper(0, "Pay L$" + (string)price + " to buy");
            }
            else
            {
                llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_TEXTURE,  counter));
            }
        }
    }
    timer()
    {
        next();
    }
    money(key giver, integer amount)
    {
        if (amount  price)
        {
            change = amount - price;
            llSay(0, "Overpaid. vending item and giving L$" + (string)change + " change");
            llGiveMoney(giver, change);
            llGiveInventory(giver, llGetInventoryName(INVENTORY_TEXTURE,  counter));
            llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE,  counter) + " for L$" + (string)price);
        }
        else if (amount == price)
        {
            llGiveInventory(giver, llGetInventoryName(INVENTORY_TEXTURE,  counter));
        llInstantMessage(llGetOwner(), llKey2Name(giver) + " bought " + llGetInventoryName(INVENTORY_TEXTURE,  counter) + " for L$" + (string)price);
        }
    }
    on_rez(integer start_param)
    {
        llResetScript();
    }
}

 name your back button 'prev' your forward button 'next' and link them to your root prim. drop your inventory and images in and your ready to go!

Drinkinsteins Gatcha Script

/////////////////////////////////////
/////////////////////////////////////
integer price = 15;  //SET PRICE HERE
/////////////////////////////////////
/////////////////////////////////////
//DrinkInstein Sorbet Open Source Gatcha Script. I am releasing this code under the Simplified BSD License.
//Copyright 2010 "Drinkinstein Sorbet" All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice, this list of
//      conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice, this list
//      of conditions and the following disclaimer in the documentation and/or other materials
//     provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY "Drinkinstein Sorbet" ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL "Drinkinstein Sorbet OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of "Drinkinstein Sorbet".



key requestid;
string avatar;

default
{
    state_entry()
    {
        llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
        
    }
    touch_start(integer number)
    {   
        string id = llDetectedKey(0);
        string scriptname = llGetScriptName();
        llPlaySound("0e20b5f9-1b06-843e-446c-49fee8827448", 1.0);
        llInstantMessage(id, "Click pay to play the Gatcha!");
    }
    money(key id, integer amount) 
       {
        list items;
        list finalitems;
        string name;
        string stuff;
        string returnitem;
        integer num = llGetInventoryNumber(INVENTORY_ALL);
        integer finalnum = num - 1;
        string folder = llGetObjectName();
        integer i;
        integer min = 0;
        string scriptname = llGetScriptName();
        
        
        integer random = (integer)llFrand(finalnum);
        if(random == num) {
            random -= 1 ;
            }
        for (i = 0; i 

 

Vendor that sells to Only One Person

//Title: Vendor to Sell to Only One Person //Date: 01-28-2004 04:38 PM //Version: 1.0.0 //Scripter: Ama Omega // string name = "Nameofpersonbuying"; integer price = 10; // adjust accordingly string item = "nameofitem"; default { state_entry() { llRequestPermissions( llGetOwner(), PERMISSION_DEBIT ); } run_time_permissions(integer perms) { if (perms & PERMISSION_DEBIT) state run; } } state run { money(key id, integer amount) { if (llKey2Name(id) == name) { if (amount != price) { llWhisper(0,"Sorry! The price is $" + (string)price); llGiveMoney(id,amount); } else { llGiveInventory(id,item); llInstantMessage(llGetOwner(),name + " bought their item."); state sold; } } else { llWhisper(0,"Sorry I'm only selling this to " + name); llGiveMoney(id,amount); } } } state sold { state_entry() { } }