Edie_Shoreland

No Sleep Tipjar (Captcha check)

Apr 24th, 2019
623
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Type the split between employee and club owner in the
  2. //object description.  Type the owner's take percentage
  3. //in integer format only...DON'T USE decimals, DON'T USE
  4. //"$" or "%". If the employee gets 100% of their tips,
  5. //simply put a 0 in the object description, if the em-
  6. //ployee gets 90%, then put a 10 in object description.
  7.  
  8. //Numbers like 0 or 10 or 50 are fine, NOT 15.0, $10L or
  9. //20%.  Non-integer descriptions will more likely return
  10. //an "Invalid amount for llGiveMoney()" error
  11.  
  12. //Once you change the description for the new tip split
  13. //you will need to RESET this script. Make sure the tip
  14. //split is in the tip jar's description, not the script's.
  15.  
  16. key clubOwner; //This is the prim owner's key, not the employee's
  17. integer percentage; //This is the amount in the object description
  18.                     //and the tip percentage that goes to the owner.
  19.  
  20. key keyactive;     //These are the key and name for the employee
  21. string nameactive; //currently logged into the tipjar.
  22. string capAnswer;
  23.  
  24. integer handle;
  25. integer onlineCheck;
  26. integer chanl;
  27.  
  28. float checkCycle = 3600.0; //3600.0 = one hour, 1800.0 = 30 minutes
  29. float testCycle = 90.0; //Employee has 90 seconds to respond to the captcha.
  30.  
  31. list randomSum ()
  32. {
  33.     list question;
  34.     integer x = (integer)llFrand(40) + 15;
  35.     integer y = (integer)llFrand(x);
  36.     integer z = x - y;
  37.     question = [(string)x, (string)y, (string)z];
  38.     return question;
  39. }
  40.  
  41. list captchaList (string answer)
  42. {
  43.     string herring;
  44.     integer counInt;
  45.     integer randInt;
  46.     list captjazz = [answer];
  47.     for (counInt=1;counInt<=11;++counInt)
  48.     {
  49.         randInt = (integer)llFrand(55);
  50.         herring = (string)randInt;
  51.         if (~llListFindList(captjazz,[herring]))
  52.         {
  53.             //this doesn't prevent duplicates, it only
  54.             //prevents duplicates of the correct answer
  55.             herring = (string)(randInt + 55);
  56.             captjazz = captjazz + herring;
  57.         }
  58.         else captjazz = captjazz + herring;
  59.     }
  60.     return llListRandomize(captjazz,1);
  61. }
  62.  
  63. default
  64. {
  65.     on_rez(integer param)
  66.     {
  67.         llResetScript();
  68.     }
  69.    
  70.     state_entry()
  71.     {
  72.         //llSetStatus(STATUS_PHYSICS, TRUE);
  73.         clubOwner = llGetOwner();
  74.         percentage = (integer)llGetObjectDesc();
  75.         llSetText("Tip jar inactive", <1,1,1> ,1.0);
  76.         llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
  77.     }
  78.    
  79.     run_time_permissions (integer perm)
  80.     {
  81.         if (perm == PERMISSION_DEBIT)
  82.         {
  83.             state active;  
  84.         }
  85.         else
  86.         {
  87.             llOwnerSay("I need those permissions. Please reset me to try again.");
  88.         }
  89.     }
  90.  
  91. }
  92.  
  93. state active
  94. {
  95.     on_rez(integer param)
  96.     {
  97.         llResetScript();
  98.     }
  99.    
  100.     state_entry()
  101.     {
  102.         llSetText("Tip jar unassigned",<1,1,1>,1.0);  
  103.         llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
  104.     }  
  105.    
  106.    
  107.     touch_start(integer nr)
  108.     {
  109.         key toucher = llDetectedKey(0);
  110.         if (toucher == keyactive && llSameGroup(toucher) == TRUE)
  111.         {
  112.             keyactive = NULL_KEY;
  113.             nameactive = "";
  114.             llSetText("Tip jar unassigned",<1,1,1>,1.0);
  115.             llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
  116.             llSetTimerEvent(0.0);
  117.         }
  118.         else if (llSameGroup(toucher) == TRUE)
  119.         {
  120.             keyactive = toucher;
  121.             nameactive = llKey2Name(toucher);
  122.             llSetText(nameactive+"'s tip jar",<1,1,1>, 1.0);
  123.             llSetPayPrice(PAY_DEFAULT, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]);
  124.             llSetTimerEvent(checkCycle);
  125.             onlineCheck = FALSE;
  126.         }
  127.  
  128.     }
  129.    
  130.     money(key id, integer amount)
  131.     {
  132.         integer split = llRound((amount * percentage) / 100);
  133.         integer tipreceiver = amount - split;
  134.         llGiveMoney(keyactive, tipreceiver);
  135.         llGiveMoney(clubOwner, split);
  136.        
  137.         llSay(0,"Thank you for your donation.");
  138.     }
  139.  
  140.     timer()
  141.     {
  142.         if (onlineCheck)
  143.         {
  144.             keyactive = NULL_KEY;
  145.             nameactive = "";
  146.             llSetText("Tip jar unassigned",<1,1,1>,1.0);
  147.             llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
  148.             llSetTimerEvent(0.0);
  149.             onlineCheck = FALSE;
  150.             llListenRemove(handle);
  151.         }
  152.         else
  153.         {
  154.             string uniq_chan = (string)llGetKey( ); //get the object key
  155.             uniq_chan = "0x" + (llGetSubString(uniq_chan, 6, 7)) + (llGetSubString(uniq_chan, 11, 12));
  156.             integer poschan = (integer)uniq_chan; //establish a channel using parts of that key.
  157.             chanl = 0 - poschan;
  158.             handle = llListen(chanl, "", "", "");
  159.             list captQues = randomSum();
  160.             capAnswer = llList2String(captQues,0);
  161.             list buttonz = captchaList(capAnswer);
  162.             llDialog(keyactive, "What is " + llList2String(captQues,1) + " + " + llList2String(captQues,2) + "?\nYou have 90 seconds to answer before being automatically logged out.", buttonz, chanl);
  163.             onlineCheck = TRUE;
  164.             llSetTimerEvent(testCycle);
  165.         }
  166.     }
  167.     listen(integer chan, string name, key id, string msg)
  168.     {
  169.         if (msg == capAnswer)
  170.         {
  171.             llSay(0,"Correct Answer");
  172.             onlineCheck = FALSE;
  173.             llListenRemove(handle);
  174.             llSetTimerEvent(checkCycle);
  175.         }  
  176.     }
  177. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×