added jaunter scripts and tools.
[feisty_meow.git] / huffware / huffotronic_tools_n_testers_v6.1 / report_to_merchants_v1.3.txt
1 
2 // huffware script: report to merchants, by fred huffhines.
3 //
4 // this script lets merchants know that one of their items has been rezzed or attached.
5 // it only reports this the first time it happens.
6
7 // global constants...
8
9 integer SCRIPT_ZAPS_SELF_AFTER_REPORT = FALSE;
10     // if this is true, the script will destroy itself once it reports the object rez or attach.
11
12 // the list of UUIDs for reporting the customer event.
13 list IDS_TO_ALERT = [
14 //    "addfa58f-e42e-4dde-9eb0-755bbf4e23ec",  // damara's alt.
15     "71649242-6abe-4288-b45b-a057621d35ea"   // fred.
16 ];
17
18 // the list of emails that should be alerted.
19 list EMAILS_TO_ALERT = [
20 //    "damradbruch@hotmail.com",  // damara's alt email.
21     "fred@gruntose.com"         // fred.
22 ];
23
24 // global variables...
25
26 integer REPORTED_ABOUT_REZ = FALSE;  // did we tell the merchants yet?
27
28 key CURRENT_OWNER = NULL_KEY;  // the guy who owns the hud right now.
29
30 // helper functions...
31
32 // let the merchants who sold this product know that it was either rezzed or attached.
33 // either event should cause a nice report to them.
34 alert_the_merchants(string word)
35 {
36     integer i;
37     if (CURRENT_OWNER != llGetOwner()) {
38         // if the owner has changed, then we always believe that we need to report.
39         REPORTED_ABOUT_REZ = FALSE;
40         CURRENT_OWNER = llGetOwner();
41     }
42     if (!REPORTED_ABOUT_REZ) {
43         // we have not reported before (for this owner), so we can tell the merchants now.
44         REPORTED_ABOUT_REZ = TRUE;
45         string message_for_merchants = "Your product '" + llGetObjectName() + "' was "
46             + word + " by " + llKey2Name(llGetOwner())
47             + " in " + llGetRegionName()
48             + " at " + llGetTimestamp();
49         // send instant messages about this event.
50         for (i = 0; i < llGetListLength(IDS_TO_ALERT); i++) {
51             key id = (key)llList2String(IDS_TO_ALERT, i);
52             llInstantMessage(id, message_for_merchants);
53         }
54         // send emails about it too.
55         for (i = 0; i < llGetListLength(EMAILS_TO_ALERT); i++) {
56             string addr = llList2String(EMAILS_TO_ALERT, i);
57             llEmail(addr, "customer event for " + llKey2Name(llGetOwner())
58                 + " regarding " + llGetObjectName(),
59                 message_for_merchants);
60         }
61         // see if the script should go away now.
62         if (SCRIPT_ZAPS_SELF_AFTER_REPORT) {
63             llRemoveInventory(llGetScriptName());
64         }
65     }    
66 }
67
68 default
69 {
70     state_entry() { CURRENT_OWNER = llGetOwner(); }
71     
72     attach(key id) {
73         if (id != NULL_KEY) { alert_the_merchants("attached"); }
74     }
75
76     on_rez(integer start_parm) { alert_the_merchants("rezzed"); }
77 }
78