|
Perl Hallstrom
Registered User
Join date: 12 Jun 2007
Posts: 33
|
12-16-2007 16:15
I need help to get a simple lottery script.
I am going to use it at a Christmas party Everyone will bring a present and the we will have a lottery where you get one of the presents. I think we will be about 20 persons. So its not so advanced. Just a lottery wher you everyone gets a number and then can get the Christmas present with that number.
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
12-16-2007 20:24
I can see problems if you try to have the people involved drop the presents in an object which then gives it out (because you don't know who dropped in the present for the list to give out... so instead I came up with something a bit more like secret santa (but should work just as well... list gLstParticipants;
default{ touch_start( integer vIntTouches ){ do{ --vIntTouches; key vKeyAvatar = llDetectedKey( vIntTouches ); if (~llListFindList( gLstParticipants, (list)vKeyAvatar )){ if (vKeyAvatar == llGetOwner()){ llInstantMessage( vKeyAvatar, "Say '/start' to begin the name exchange" ); llListen( 0, "", vKeyAvatar, "/start" ); llSetTimerEvent( 60.0 ); }else{ llInstantMessage( vKeyAvatar, "You've already been entered." ); } }else{ gLstParticipants += (list)vKeyAvatar; llInstantMessage( vKeyAvatar, "You've been added." ); } }while (vIntTouches); }
listen( integer vIntNull, string vStrNull, key vKeyNull, string vStrNull2 ){ list vLstRandom = llListRandomize( gLstParticipants, 1 ); integer vIntCount = llGetListLength( vLstRandom ); do{ --vIntCount; llInstantMessage( llList2Key( gLstParticipants, vIntCount ), "Your Gift goes to " + llKey2Name( llList2Key( vLstRandom, vIntCount ) ) ); }while (vIntCount); }
timer(){ llSetTimerEvent( 0.0 ); state sListenKill; } }
state sListenKill{ state_entry(){ state default; } }
just like a real random gift exchange / secret santa, it's possible the person that puts in a gift will get it back... with a little creative list manipulation you can prevent that by matching people together or some other method of checking
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|