Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //for use by developers who want to track sales in world.
- //this script triggers when an item is delivered
- //place one in each item server that you want to record from
- // Insert Your Webhook-URL here:
- string WEBHOOK_URL = "https://discord.com/api/webhooks/987957068390613034/XZg4aV1YfwcnHLzN2GlmZup4xXbNcMF5LV9YkJmqdFy7I4PpsDUHK1BAzMV1s2HOdzzV";
- integer WEBHOOK_WAIT = TRUE;
- string TTS = "TRUE"; // Text To Speech
- key REQUEST_KEY;
- key SendToDiscord(string name, string message)
- {
- string query_string = "";
- if(WEBHOOK_WAIT) query_string += "?wait=true";
- return
- llHTTPRequest
- (
- WEBHOOK_URL + query_string,
- [
- HTTP_METHOD, "POST",
- HTTP_MIMETYPE, "application/json",
- HTTP_VERIFY_CERT, TRUE,
- HTTP_PRAGMA_NO_CACHE, TRUE,
- HTTP_VERBOSE_THROTTLE, TRUE
- ],
- llList2Json(JSON_OBJECT,
- [
- "username", name,
- "content", message,
- "tts", TTS
- ])
- );
- }
- default
- {
- link_message(integer send, integer num, string message, key id)
- {
- if(num == -1111 && message !="")//transaction data input
- {
- string product;//unique product name
- string buyer_name;//avatar who paid
- key buyer_key;
- string receiver_name;//avatar who owns the item
- key receiver_key;
- integer paid;//amount of lindens paid
- integer product_id;
- string item;//name of server item for this product
- string transaction_type;//buy, gift, resend, demo
- integer record_id;//sales id, demo id or resend record id
- string datetime;
- if(llJsonGetValue(message,["product"])!= JSON_INVALID)
- product = llJsonGetValue(message,["product"]);
- if(llJsonGetValue(message,["buyer_key"])!= JSON_INVALID)
- buyer_key = (key)llJsonGetValue(message,["buyer_key"]);
- if(llJsonGetValue(message,["buyer_name"])!= JSON_INVALID)
- buyer_name = llJsonGetValue(message,["buyer_name"]);
- if(llJsonGetValue(message,["receiver_key"])!= JSON_INVALID)
- receiver_key = (key)llJsonGetValue(message,["receiver_key"]);
- if(llJsonGetValue(message,["receiver_name"])!= JSON_INVALID)
- receiver_name = llJsonGetValue(message,["receiver_name"]);
- if(llJsonGetValue(message,["paid"])!= JSON_INVALID)
- paid = (integer)llJsonGetValue(message,["paid"]);
- if(llJsonGetValue(message,["product_id"])!= JSON_INVALID)
- product_id = (integer)llJsonGetValue(message,["product_id"]);
- if(llJsonGetValue(message,["item"])!= JSON_INVALID)
- item = llJsonGetValue(message,["item"]);
- if(llJsonGetValue(message,["type"])!= JSON_INVALID)
- transaction_type = llJsonGetValue(message,["type"]);
- if(llJsonGetValue(message,["record_id"])!= JSON_INVALID)//id of sale, demo or resend record
- record_id = (integer)llJsonGetValue(message,["record_id"]);
- if(llJsonGetValue(message,["datetime"])!= JSON_INVALID)
- datetime = llJsonGetValue(message,["datetime"]);
- //do stuff with the data...
- llOwnerSay("datetime:"+datetime+
- "\ntransaction type:"+transaction_type+
- "\nbuyer:"+buyer_name+" "+(string)buyer_key+
- "\nreceiver:"+receiver_name+" "+(string)receiver_key+
- "\nproduct:"+product+
- "\nproduct id:"+(string)product_id+
- "\nserver item:"+(string)item+
- "\npaid:"+(string)paid+
- "\nrecord id:"+(string)record_id);
- string sendText = "Hello! "+buyer_name+" just bought a '"+item+"' from you";
- REQUEST_KEY = SendToDiscord(buyer_name, sendText);
- }
- }
- http_response(key request_id, integer status, list metadata, string body)
- {
- if(REQUEST_KEY==request_id && WEBHOOK_WAIT);// llOwnerSay(body);
- }
- }
Add Comment
Please, Sign In to add comment