/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// list _contestK = []; key _owner = NULL_KEY; default { state_entry() { _owner = llGetOwner(); llSetText("♣ Click to join the contest! ♣", <1,1,1>, 1); } touch_start(integer num) { key ct = llDetectedKey(0); if(ct == llGetOwner()) jump owner; if(llListFindList(_contestK, (list)ct) != -1) return; _contestK += ct; list pot = []; num = llGetListLength(_contestK)-1; do { pot += llKey2Name(llList2Key(_contestK, num)); } while(--num>=0); llSetText("♣ Raffle! ♣\n" + llDumpList2String(pot, "\n"), <1,1,1>, 1); return; @owner; if(llGetListLength(_contestK) == 0) return; integer comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF + (integer)("0x"+llGetSubString((string)_owner,-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; llListen(comChannel, "", _owner, ""); llDialog(_owner, "\nPlease sleect from the options below:\n", [ "$ Payout $", "Manual" ], comChannel); } listen(integer channel, string name, key id, string message) { if(message == "$ Payout $") state payout; integer win = (integer)llFrand(llGetListLength(_contestK)); llShout(0, "The winner is: " + llKey2Name(llList2Key(_contestK, win)) + "!"); llResetScript(); } on_rez(integer pin) { _owner = llGetOwner(); } changed(integer change) { if(change & CHANGED_OWNER) _owner = llGetOwner(); } } state payout { state_entry() { llRequestPermissions(_owner, PERMISSION_DEBIT); } run_time_permissions(integer perm) { if(perm & PERMISSION_DEBIT) { integer win = (integer)llFrand(llGetListLength(_contestK)); llSay(0, "The winner is: " + llKey2Name(llList2Key(_contestK, win)) + "!"); llGiveMoney(llList2Key(_contestK, win), (integer)llGetObjectDesc()); llResetScript(); } } }