Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Give asst'd prizes script...

SeXXXy Bliss
SL Addict
Join date: 21 Dec 2004
Posts: 436
05-31-2005 11:03
I have seen it before and would love to have the script that allows a prim object to give out different objects at random...hopefully it hasn't been previously posted and I missed it!

I am creating a clown that will give out prizes when touched.

All responses would be greatly appreciated...

Thank you,
SeXXXy
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-31-2005 11:24
This script should work. I haven't actually tested it, though, because I haven't been able to log in. Enjoy.

CODE

integer numobjects;
integer i;
string randomobject;

default
{
on_rez( integer sparam )
{
llResetScript(); //Reset when rezzed, to prevent weird bugs
}
state_entry()
{
numobjects = llGetInventoryNumber( INVENTORY_OBJECT ); //Get the number of objects in the inventory
}
touch_start( integer num ) //When it's touched, give stuff away
{
for ( i = 0 ; i < num ; i++ ) //Do this for everyone
{
randomobject = llGetInventoryName( INVENTORY_OBJECT , (integer)(llFrand(numobjects) ) ); //Get a random object's name from the inventory
llGiveInventory( llDetectedKey( i ) , randomobject ); //Give the user the random object
llInstantMessage( llDetectedKey( i ) , "Enjoy your shiny new " + randomobject + ", "+llDetectedName(i)+"!"); //Congratulate the clicker
}
}
}
SeXXXy Bliss
SL Addict
Join date: 21 Dec 2004
Posts: 436
Thank You!!!
05-31-2005 20:16
Your script worked just fine...you are a god!!