Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Event Lottery Script

Ama Omega
Lost Wanderer
Join date: 11 Dec 2002
Posts: 1,770
09-19-2003 11:35
This is a simple script for randomly awarding money to event attendies. Everyone who wishes to enter simply clicks the object the script is on. To find a winner the owner of the object says 'Find Winner'. This can be repeated as often as needed to find as many winners as possible. After a name has 'won' it is removed from the pool. This is a simple script.

CODE
list names;
integer i;
integer j;
integer count;
string name;

integer find(string name)
{
for (i=0;i<count;i++)
if (llList2String(names,i) == name)
return i;
return -1;
}

default
{
state_entry()
{
llListen(0,"",llGetOwner(),"Find Winner");
count = 0;
}

touch_start(integer total_number)
{
for (j=0;j<total_number;j++)
{
if (find(llDetectedName(j)) == -1)
{
name = llDetectedName(j);
names += name;
llSay(0,name + " has been entered.");
count++;
}
}
}

listen(integer chan, string name, key id, string mes)
{
names = llListRandomize(names,1);
i = llFloor(llFrand(llGetListLength(names)));
llWhisper(0,"And the Winner is " + llList2String(names,i) +
"! There were " + (string)count + " participants.");
llDeleteSubList(names,i,i);
}
}
Floyd Gilmour
Registered User
Join date: 5 Jul 2006
Posts: 149
07-07-2006 15:40
Is there any way to make it only give out a certain percentage of the pot?
For example 80% given to winner, 20% to the object owner?
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
07-08-2006 08:44
/15/ba/5356/1.html
_____________________
i've got nothing. ;)
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-30-2006 14:38
From: Floyd Gilmour
Is there any way to make it only give out a certain percentage of the pot?
For example 80% given to winner, 20% to the object owner?

Doesn't hand out money. Only announces a, "winner."
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
07-30-2006 14:42
DEFECT

Symptoms:
Winner will not be removed.

Problem:
'llDeleteSubList' does not modify a list in place; it RETURNS a new version of the list.

Solution:
Change last statement in script to:
CODE
names = llDeleteSubList(names, i, i);