Lottery
De DigiWiki.
Version du 16 mars 2013 à 21:30 par Djphil (discuter | contributions)
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); } }