Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer Perms;
  2. key Owner;
  3. key Vendor_Key;
  4. key Customer_Key;
  5. key Gift_Key;
  6. string Customer_Name;
  7. string Gift_Name;
  8. string Product = "test Gayngel234";
  9. string url;
  10. integer Paid_Amount;
  11. string Payment_Method;
  12. integer Discount_All;
  13. integer Discount_Group;
  14. string Date;
  15. string Region;
  16. string Sale_Start;
  17. string Sale_End;
  18. integer Price = 399;
  19. integer Reward_All;
  20. integer Reward_Group;
  21. integer lchan;
  22. integer lhandle;
  23. integer dchan;
  24. integer dhandle;
  25. integer gdisc_chan;
  26. integer adisc_chan;
  27. integer lgroup_disc;
  28. integer lall_disc;
  29. list Investors;
  30. key requestURL;
  31. key checkReg;
  32. key checkBan;
  33. key callServer;
  34. key returnBan;
  35. key PayPartner;
  36. key partner;
  37. integer share;
  38. list admin_btns =["Set Active","Configure","Reset","Sales Dates","Discounts","Profit Split","Ban"];
  39. list customer_btns = ["Gift","Credit"];
  40. integer Active = TRUE;
  41.  
  42.  
  43.  
  44. Dialog(key av,list btns)
  45. {
  46.  llListenRemove(lhandle);
  47.  lhandle = llListen(lchan,"",av,"");
  48.  llDialog(av,"\nSelect an option:",btns,lchan);
  49.  
  50.  Timer();  
  51. }
  52.  
  53. Timer()
  54. {
  55.  
  56.  llSetTimerEvent(0.0);
  57.   llSetTimerEvent(120.0);
  58.    
  59. }
  60.  
  61. init()
  62. {
  63.  
  64.     llReleaseURL(url);
  65.     requestURL = llRequestURL();
  66.  
  67. }
  68.  
  69.  
  70. Ping()
  71. {    
  72.    
  73.  //   llHTTPRequest(app+"?"+"url="+url+"&uuid="+ llEscapeURL(llGetKey()) + "&version=" + llEscapeURL(version),[HTTP_METHOD,"GET"],"Ping");
  74.  
  75.  
  76.  
  77. // Ping store php  
  78.  
  79.   // checkReg = llHTTPRequest();
  80.  
  81.  
  82.  
  83.    llHTTPRequest("http://agorasl.com/stores/include/lsl/insertproduct.php",[HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"],
  84.            "Owner="+(string)llGetOwner()+
  85.            "&Product="+(string)Product+
  86.            "&Price="+(string)Price+
  87.            "&Active="+(string)Active+
  88.            "&Region="+(string)Region+
  89.            "&Sale_Start="+(string)Sale_Start+
  90.            "&Sale_End="+(string)Sale_End+
  91.             "&Date="+(string)Date+
  92.            "&Discount_All="+(string)Discount_All+
  93.          "&Discount_Group="+(string)Discount_Group+
  94.             "&Reward_All="+(string)Reward_All+
  95.             "&Reward_Group="+(string)Reward_Group
  96.             );
  97.  
  98.    
  99.  
  100. }
  101.  
  102.  
  103. setDiscount(integer sdisc,string smsg)
  104. {
  105.    
  106.     if (llGetSubString(smsg, -1, -1) == llUnescapeURL("%0A") )
  107.             smsg = llStringTrim(llGetSubString(smsg, 0, -2),STRING_TRIM_HEAD);
  108.    
  109.      integer idx = llSubStringIndex(smsg,"%");
  110.      
  111.      if(~idx)
  112.      smsg = llGetSubString(smsg, 0, -2);
  113.      
  114.      
  115.      if(sdisc = gdisc_chan)
  116.      {
  117.      Discount_Group = (integer)smsg;
  118.      llInstantMessage(Owner,"Group discount has been set to " +(string)Discount_Group+ "%.");
  119.      }
  120.      else if(sdisc = adisc_chan)
  121.      {
  122.      Discount_All = (integer)smsg;
  123.     llInstantMessage(Owner,"The discount for everyone has been set to " +(string)Discount_All+ "%.");
  124.     }
  125.    
  126. }
  127.  
  128.  
  129. default
  130. {
  131.    
  132.    
  133.     state_entry()
  134.     {
  135.        
  136.       Owner = llGetOwner();
  137.       Vendor_Key = llGetKey();
  138.       lchan = ((integer)("0x"+llGetSubString((string)Vendor_Key,-8,-1)) - 723) | 0x8000000;
  139.       dchan = ((integer)("0x"+llGetSubString((string)Vendor_Key,-8,-1)) - 3472) | 0x8000000;
  140.  
  141.       gdisc_chan = ((integer)("0x"+llGetSubString((string)Vendor_Key,-8,-1)) - 47687) | 0x8000000;
  142.  
  143.       adisc_chan = ((integer)("0x"+llGetSubString((string)Vendor_Key,-8,-1)) - 255) | 0x8000000;
  144.  
  145.         //llRequestPermissions(Owner,PERMISSION_DEBIT);
  146.         init();
  147.  
  148.  
  149.     }
  150.    
  151.    
  152.     run_time_permissions(integer perm)
  153.     {
  154.      
  155.       if(perm & PERMISSION_DEBIT)
  156.       {
  157.          
  158.           Perms = TRUE;
  159.           init();
  160.          
  161.          
  162.          
  163.         }
  164.        
  165.         else
  166.         {
  167.         llInstantMessage(Owner,"This vendor can not be used without granting debit permissions.");
  168.         Perms = FALSE;
  169.        
  170.         }
  171.        
  172.        
  173.     }
  174.    
  175.  
  176.     touch_end(integer total_number)
  177.     {
  178.          key Toucher = llDetectedKey(0);  
  179.       if(Perms)
  180.       {  
  181.      
  182.        
  183.        
  184.        if(Toucher == Owner)
  185.        Dialog(Toucher,admin_btns);
  186.        
  187.        else
  188.        Dialog(Toucher,customer_btns);
  189.        }
  190.        
  191.        else
  192.        {
  193.          
  194.           if(Toucher == Owner)
  195.           {
  196.               llRequestPermissions(Owner,PERMISSION_DEBIT);
  197.           }
  198.            
  199.         }
  200.        
  201.     }
  202.    
  203.    
  204.      http_request(key id, string method, string body)
  205.     {
  206.        
  207.          if ((method == URL_REQUEST_GRANTED) && (id == requestURL) )
  208.         {
  209.             // An URL has been assigned to me.
  210.             url = body;
  211.             requestURL = NULL_KEY;
  212.             Ping();
  213.         }
  214.         else if ((method == URL_REQUEST_DENIED) && (id == requestURL))
  215.         {
  216.             // I could not obtain a URL
  217.             llOwnerSay("There was a problem, and an URL was not assigned: " + body);
  218.             requestURL = NULL_KEY;
  219.         }
  220.        
  221.         else if(id == checkBan)
  222.         {
  223.            
  224.            if(body == "Yes")
  225.            {
  226.                
  227.               llInstantMessage(Customer_Key,"You are banned from this store, you can not buy items from this vendor.");
  228.               returnBan = llTransferLindenDollars(Customer_Key,Paid_Amount);
  229.  
  230.                
  231.             }
  232.                
  233.                
  234.            else if(body == "No")
  235.             {
  236.                    
  237.                integer itemcheck = llGetInventoryType(Product);
  238.                
  239.                if(itemcheck == INVENTORY_NONE)
  240.                {
  241.                    callServer = llHTTPRequest("serverurl.com",[HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"],
  242.              "Owner="+(string)llGetOwner()+
  243.              "&Product="+(string)Product);
  244.                    
  245.                 }
  246.                
  247.                else
  248.                 llGiveInventory(Customer_Key,Product);
  249.                
  250.                
  251.            
  252.                    
  253.             }
  254.              
  255.            
  256.          }
  257.     }
  258.    
  259.     http_response(key id, integer status, list metadata, string body)
  260.     {
  261.        
  262.         if(id == checkReg)
  263.         {
  264.            
  265.             if(body == "Yes")
  266.             {
  267.                 llOwnerSay("Please go to the web portal to set up this vendor.");
  268.                //  llLoadURL(Owner, "You need to register your store before setting up this vendor. Click this link to register.", "https://agorasl.com/stores/signup.php." );
  269.              }
  270.            
  271.            
  272.             else if(body == "No")
  273.             {
  274.               llOwnerSay("You need to register your store before setting up this vendor. Please register at https://agorasl.com/stores/signup.php.");  
  275.               llLoadURL(Owner, "You need to register your store before setting up this vendor. Click this link to register.", "https://agorasl.com/stores/signup.php." );
  276.                
  277.                
  278.              }    
  279.            
  280.         }
  281.        
  282.         llOwnerSay((string)id + "+" + (string)status +"+ List=" +llList2CSV(metadata)+"+"+body);
  283.        
  284.     }
  285.    
  286.    
  287.    
  288.     listen(integer chan, string name, key id, string msg)
  289. {
  290.    
  291.    
  292.     //list admin_btns =["Set Active","Configure","Reset","Sales Dates","Discounts","Profit Split"];
  293. //list customer_btns = ["Gift","Credit"];
  294.    
  295.     if(chan == lchan)
  296.     {
  297.  
  298.         if(msg == "Set Active")
  299.         {
  300.            
  301.            if(Active)
  302.            {
  303.                Active = FALSE;
  304.                 llSetPayPrice(PAY_HIDE,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
  305.                 llSetClickAction(CLICK_ACTION_TOUCH);
  306.                
  307.                llOwnerSay("You have set this vendor to inactive. No one can buy products from it.");
  308.                
  309.             }
  310.            
  311.            else if(!Active)
  312.             {
  313.                Active = TRUE;
  314.               llSetClickAction(CLICK_ACTION_PAY);
  315.                 llSetPayPrice(Price,[PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
  316.                
  317.                 llOwnerSay("You have set this vendor to active. Evertone can buy from it.");
  318.                
  319.                 }
  320.            
  321.            
  322.         }
  323.        
  324.        
  325.         else if (msg == "Configure")
  326.         {
  327.            
  328.             llOwnerSay("Please go to the web portal to set up this vendor.");
  329.            
  330.            
  331.         }  
  332.        
  333.         else if (msg == "Reset")
  334.         {
  335.            
  336.           // llResetScript();
  337.            
  338.         }  
  339.        
  340.        
  341.         else if (msg == "Sales Dates")
  342.         {
  343.             llListenRemove(lhandle);
  344.            llMessageLinked(LINK_SET,0,"SetSale","");
  345.            
  346.         }
  347.        
  348.         else if (msg == "Discounts")
  349.         {
  350.            
  351.             llListenRemove(lhandle);
  352.             llListenRemove(dhandle);
  353.             dhandle = llListen(dchan,"",id,"");
  354.            
  355.             llDialog(id,"\nSelect to set a discount for group and/or everyone.",["Group","Everyone"],dchan);
  356.            
  357.         }  
  358.        
  359.         else if (msg == "Profit Split")
  360.         {
  361.            
  362.             llListenRemove(lhandle);
  363.             llMessageLinked(LINK_SET,0,"SetProfit","");
  364.            
  365.         }  
  366.        
  367.        
  368.      
  369.        
  370.      }
  371.      
  372.      
  373.      else if(chan == dchan)
  374.      {
  375.        
  376.         if(msg == "Group")
  377.         {
  378.             llListenRemove(dhandle);
  379.             llListenRemove(lgroup_disc);
  380.             lgroup_disc = llListen(gdisc_chan,"",id,"");
  381.            
  382.          llTextBox(id,"\nSet the discount rate for group members. Type the percentage into the text box.",gdisc_chan);
  383.          
  384.            
  385.         }
  386.        
  387.         else if(msg == "Everyone")
  388.         {
  389.            llListenRemove(dhandle);
  390.             llListenRemove(lall_disc);
  391.              lall_disc = llListen(adisc_chan,"",id,"");
  392.              llTextBox(id,"\nSet the discount rate for everyone. Type the percentage into the text box.",adisc_chan);
  393.            
  394.         }
  395.          
  396.       }
  397.      
  398.      
  399.       else if(chan == gdisc_chan)
  400.       {
  401.          
  402.           setDiscount(gdisc_chan,msg);
  403.       }
  404.      
  405.      
  406.       else if(chan == adisc_chan)
  407.       {
  408.      
  409.         setDiscount(adisc_chan,msg);
  410.        
  411.       }
  412.      
  413.      
  414. }
  415.    
  416.    
  417.     money(key id, integer amount)
  418.     {
  419.         if(Active)
  420.         {
  421.          
  422.           //check banlist checkBan = llHTTPRequest();
  423.            
  424.         }
  425.        
  426.         else
  427.         {
  428.            
  429.            
  430.         }
  431.      
  432.      
  433.      }
  434.      
  435.      link_message(integer sender, integer num, string msg, key id)
  436.      {
  437.          
  438.        if(msg == "PayP")
  439.        {
  440.          partner = id;
  441.          share = num;
  442.          PayPartner = llTransferLindenDollars(id,num);  
  443.          
  444.            
  445.         }  
  446.          
  447.      }
  448.    
  449.    
  450.     changed(integer change)
  451.     {
  452.         //  note that it's & and not &&... it's bitwise!
  453.         if (change & (CHANGED_REGION | CHANGED_REGION_START | CHANGED_TELEPORT))
  454.         {
  455.             init();
  456.         }
  457.  
  458.         else if (change & (CHANGED_OWNER))
  459.         llResetScript();
  460.        
  461.     }
  462.    
  463.     transaction_result(key id, integer success, string data)
  464.     {
  465.        
  466.         if(id == returnBan)
  467.             {
  468.                
  469.               if(!success)
  470.               {
  471.                
  472.                 llInstantMessage(Customer_Key,"There was an error returning your money. Please contact "+"secondlife:///app/agent/" + (string)Owner + "/about"+" to get your money back.");
  473.                  
  474.                  llInstantMessage(Owner,"There was an error returning L$"+(string)Paid_Amount+" to "+"secondlife:///app/agent/" + (string)Customer_Key + "/about"+". Please return the money to them manually.\n\n Reason for error: " + data +".\nYou can view what this reason means here: http://wiki.secondlife.com/wiki/Transaction_result");
  475.                  
  476.                  
  477.               }
  478.                
  479.                
  480.                
  481.             }
  482.            
  483.            
  484.             else if(id == PayPartner)
  485.             {
  486.                
  487.              
  488.               if(!success)
  489.               {
  490.                
  491.                 llInstantMessage(partner,"There was an error paying your share from this vendor. Please contact "+"secondlife:///app/agent/" + (string)Owner + "/about"+" to receive your share.");
  492.                  
  493.                  llInstantMessage(Owner,"There was an error paying "+"secondlife:///app/agent/" + (string)partner + "/about"+" their share of the profits from this vendor. Please manually pay them  L$"+(string)share+"\n\n Reason for error: " + data +".\nYou can view what this reason means here: http://wiki.secondlife.com/wiki/Transaction_result");
  494.                  
  495.                  
  496.                }
  497.                  
  498.                else
  499.                 {
  500.                      
  501.                      
  502.                  }
  503.                
  504.                
  505.                
  506.             }
  507.        
  508.        
  509.     }
  510.    
  511.   timer()
  512.   {
  513.      
  514.      llSetTimerEvent(0.0);
  515.      llListenRemove(lhandle);
  516.      
  517.   }  
  518.    
  519. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement