Jym_Nova

Untitled

Mar 1st, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //for use by developers who want to track sales in world.
  2. //this script triggers when an item is delivered
  3. //place one in each item server that you want to record from
  4.  
  5. // Insert Your Webhook-URL here:
  6. string WEBHOOK_URL = "https://discord.com/api/webhooks/987957068390613034/XZg4aV1YfwcnHLzN2GlmZup4xXbNcMF5LV9YkJmqdFy7I4PpsDUHK1BAzMV1s2HOdzzV";
  7.  
  8. integer WEBHOOK_WAIT = TRUE;
  9. string TTS = "TRUE"; // Text To Speech
  10. key REQUEST_KEY;
  11.  
  12. key SendToDiscord(string name, string message)
  13. {
  14.     string query_string = "";
  15.     if(WEBHOOK_WAIT) query_string += "?wait=true";
  16.     return
  17.         llHTTPRequest
  18.         (
  19.             WEBHOOK_URL + query_string,
  20.             [
  21.                 HTTP_METHOD,            "POST",
  22.                 HTTP_MIMETYPE,          "application/json",
  23.                 HTTP_VERIFY_CERT,       TRUE,
  24.                 HTTP_PRAGMA_NO_CACHE,   TRUE,
  25.                 HTTP_VERBOSE_THROTTLE,  TRUE
  26.             ],
  27.             llList2Json(JSON_OBJECT,
  28.             [
  29.                 "username", name,
  30.                 "content",  message,
  31.                 "tts",      TTS
  32.             ])
  33.         );
  34. }
  35.  
  36.  
  37.  
  38. default
  39. {
  40.     link_message(integer send, integer num, string message, key id)
  41.     {
  42.         if(num == -1111 && message !="")//transaction data input
  43.         {
  44.             string product;//unique product name
  45.             string buyer_name;//avatar who paid
  46.             key buyer_key;
  47.             string receiver_name;//avatar who owns the item
  48.             key receiver_key;
  49.             integer paid;//amount of lindens paid
  50.             integer product_id;
  51.             string item;//name of server item for this product
  52.             string transaction_type;//buy, gift, resend, demo
  53.             integer record_id;//sales id, demo id or resend record id
  54.             string datetime;
  55.            
  56.             if(llJsonGetValue(message,["product"])!= JSON_INVALID)
  57.                 product = llJsonGetValue(message,["product"]);
  58.             if(llJsonGetValue(message,["buyer_key"])!= JSON_INVALID)
  59.                 buyer_key = (key)llJsonGetValue(message,["buyer_key"]);
  60.             if(llJsonGetValue(message,["buyer_name"])!= JSON_INVALID)
  61.                 buyer_name = llJsonGetValue(message,["buyer_name"]);
  62.             if(llJsonGetValue(message,["receiver_key"])!= JSON_INVALID)
  63.                 receiver_key = (key)llJsonGetValue(message,["receiver_key"]);
  64.             if(llJsonGetValue(message,["receiver_name"])!= JSON_INVALID)
  65.                 receiver_name = llJsonGetValue(message,["receiver_name"]);
  66.             if(llJsonGetValue(message,["paid"])!= JSON_INVALID)
  67.                 paid = (integer)llJsonGetValue(message,["paid"]);
  68.             if(llJsonGetValue(message,["product_id"])!= JSON_INVALID)
  69.                 product_id = (integer)llJsonGetValue(message,["product_id"]);
  70.             if(llJsonGetValue(message,["item"])!= JSON_INVALID)
  71.                 item = llJsonGetValue(message,["item"]);
  72.             if(llJsonGetValue(message,["type"])!= JSON_INVALID)
  73.                 transaction_type = llJsonGetValue(message,["type"]);
  74.             if(llJsonGetValue(message,["record_id"])!= JSON_INVALID)//id of sale, demo or resend record
  75.                 record_id = (integer)llJsonGetValue(message,["record_id"]);
  76.             if(llJsonGetValue(message,["datetime"])!= JSON_INVALID)
  77.                 datetime = llJsonGetValue(message,["datetime"]);
  78.             //do stuff with the data...
  79.  
  80.              llOwnerSay("datetime:"+datetime+
  81.             "\ntransaction type:"+transaction_type+
  82.             "\nbuyer:"+buyer_name+" "+(string)buyer_key+
  83.             "\nreceiver:"+receiver_name+" "+(string)receiver_key+
  84.             "\nproduct:"+product+
  85.             "\nproduct id:"+(string)product_id+
  86.             "\nserver item:"+(string)item+
  87.             "\npaid:"+(string)paid+
  88.             "\nrecord id:"+(string)record_id);
  89.            
  90.             string sendText = "Hello! "+buyer_name+" just bought a '"+item+"' from you";          
  91.             REQUEST_KEY = SendToDiscord(buyer_name, sendText);
  92.            
  93.            
  94.            
  95.            
  96.         }
  97.        
  98.        
  99.     }
  100.    
  101.      http_response(key request_id, integer status, list metadata, string body)
  102.     {
  103.         if(REQUEST_KEY==request_id && WEBHOOK_WAIT);// llOwnerSay(body);
  104.     }
  105. }
  106.  
  107.    
  108.        
  109.  
Add Comment
Please, Sign In to add comment