//Type the split between employee and club owner in the //object description. Type the owner's take percentage //in integer format only...DON'T USE decimals, DON'T USE //"$" or "%". If the employee gets 100% of their tips, //simply put a 0 in the object description, if the em- //ployee gets 90%, then put a 10 in object description. //Numbers like 0 or 10 or 50 are fine, NOT 15.0, $10L or //20%. Non-integer descriptions will more likely return //an "Invalid amount for llGiveMoney()" error //Once you change the description for the new tip split //you will need to RESET this script. Make sure the tip //split is in the tip jar's description, not the script's. key clubOwner; //This is the prim owner's key, not the employee's integer percentage; //This is the amount in the object description //and the tip percentage that goes to the owner. key keyactive; //These are the key and name for the employee string nameactive; //currently logged into the tipjar. string capAnswer; integer handle; integer onlineCheck; integer chanl; float checkCycle = 3600.0; //3600.0 = one hour, 1800.0 = 30 minutes float testCycle = 90.0; //Employee has 90 seconds to respond to the captcha. list randomSum () { list question; integer x = (integer)llFrand(40) + 15; integer y = (integer)llFrand(x); integer z = x - y; question = [(string)x, (string)y, (string)z]; return question; } list captchaList (string answer) { string herring; integer counInt; integer randInt; list captjazz = [answer]; for (counInt=1;counInt<=11;++counInt) { randInt = (integer)llFrand(55); herring = (string)randInt; if (~llListFindList(captjazz,[herring])) { //this doesn't prevent duplicates, it only //prevents duplicates of the correct answer herring = (string)(randInt + 55); captjazz = captjazz + herring; } else captjazz = captjazz + herring; } return llListRandomize(captjazz,1); } default { on_rez(integer param) { llResetScript(); } state_entry() { //llSetStatus(STATUS_PHYSICS, TRUE); clubOwner = llGetOwner(); percentage = (integer)llGetObjectDesc(); llSetText("Tip jar inactive", <1,1,1> ,1.0); llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } run_time_permissions (integer perm) { if (perm == PERMISSION_DEBIT) { state active; } else { llOwnerSay("I need those permissions. Please reset me to try again."); } } } state active { on_rez(integer param) { llResetScript(); } state_entry() { llSetText("Tip jar unassigned",<1,1,1>,1.0); llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); } touch_start(integer nr) { key toucher = llDetectedKey(0); if (toucher == keyactive && llSameGroup(toucher) == TRUE) { keyactive = NULL_KEY; nameactive = ""; llSetText("Tip jar unassigned",<1,1,1>,1.0); llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); llSetTimerEvent(0.0); } else if (llSameGroup(toucher) == TRUE) { keyactive = toucher; nameactive = llKey2Name(toucher); llSetText(nameactive+"'s tip jar",<1,1,1>, 1.0); llSetPayPrice(PAY_DEFAULT, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]); llSetTimerEvent(checkCycle); onlineCheck = FALSE; } } money(key id, integer amount) { integer split = llRound((amount * percentage) / 100); integer tipreceiver = amount - split; llGiveMoney(keyactive, tipreceiver); llGiveMoney(clubOwner, split); llSay(0,"Thank you for your donation."); } timer() { if (onlineCheck) { keyactive = NULL_KEY; nameactive = ""; llSetText("Tip jar unassigned",<1,1,1>,1.0); llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]); llSetTimerEvent(0.0); onlineCheck = FALSE; llListenRemove(handle); } else { string uniq_chan = (string)llGetKey( ); //get the object key uniq_chan = "0x" + (llGetSubString(uniq_chan, 6, 7)) + (llGetSubString(uniq_chan, 11, 12)); integer poschan = (integer)uniq_chan; //establish a channel using parts of that key. chanl = 0 - poschan; handle = llListen(chanl, "", "", ""); list captQues = randomSum(); capAnswer = llList2String(captQues,0); list buttonz = captchaList(capAnswer); llDialog(keyactive, "What is " + llList2String(captQues,1) + " + " + llList2String(captQues,2) + "?\nYou have 90 seconds to answer before being automatically logged out.", buttonz, chanl); onlineCheck = TRUE; llSetTimerEvent(testCycle); } } listen(integer chan, string name, key id, string msg) { if (msg == capAnswer) { llSay(0,"Correct Answer"); onlineCheck = FALSE; llListenRemove(handle); llSetTimerEvent(checkCycle); } } }