normalized perms on all files, to avoid relying on any stored executable bits in...
[feisty_meow.git] / huffware / huffotronic_scripts / report_to_merchants_v1.6.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"   // SL fred.
16     "1e7f0c5e-9d15-428b-8873-846d87a9c064"   // hal fred.
17 ];
18
19 // the list of emails that should be alerted.
20 list EMAILS_TO_ALERT = [
21 //    "damradbruch@hotmail.com",  // damara's alt email.
22     "fred@gruntose.com"         // fred.
23 ];
24
25 // global variables...
26
27 integer REPORTED_ABOUT_REZ = FALSE;  // did we tell the merchants yet?
28
29 key CURRENT_OWNER = NULL_KEY;  // the guy who owns the hud right now.
30
31 // helper functions...
32
33 // let the merchants who sold this product know that it was either rezzed or attached.
34 // either event should cause a nice report to them.
35 alert_the_merchants(string word)
36 {
37     integer i;
38     if (CURRENT_OWNER != llGetOwner()) {
39         // if the owner has changed, then we always believe that we need to report.
40         REPORTED_ABOUT_REZ = FALSE;
41         CURRENT_OWNER = llGetOwner();
42     }
43     if (!REPORTED_ABOUT_REZ) {
44         // we have not reported before (for this owner), so we can tell the merchants now.
45         REPORTED_ABOUT_REZ = TRUE;
46         string message_for_merchants = "Your product '" + llGetObjectName() + "' was "
47             + word + " by " + llKey2Name(llGetOwner())
48             + " in " + llGetRegionName()
49             + " at " + llGetTimestamp();
50         // send instant messages about this event.
51         for (i = 0; i < llGetListLength(IDS_TO_ALERT); i++) {
52             key id = (key)llList2String(IDS_TO_ALERT, i);
53             llInstantMessage(id, message_for_merchants);
54         }
55         // send emails about it too.
56         for (i = 0; i < llGetListLength(EMAILS_TO_ALERT); i++) {
57             string addr = llList2String(EMAILS_TO_ALERT, i);
58             llEmail(addr, "customer event for " + llKey2Name(llGetOwner())
59                 + " regarding " + llGetObjectName(),
60                 message_for_merchants);
61         }
62         // see if the script should go away now.
63         if (SCRIPT_ZAPS_SELF_AFTER_REPORT) {
64             llRemoveInventory(llGetScriptName());
65         }
66     }    
67 }
68
69 default {
70     state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; }
71     on_rez(integer parm) { state rerun; }
72 }
73 state rerun { state_entry() { state default; } }
74
75 state real_default
76 {
77     state_entry() { CURRENT_OWNER = llGetOwner(); }
78     
79     attach(key id) {
80         if (id != NULL_KEY) { alert_the_merchants("attached"); }
81     }
82
83     on_rez(integer start_parm) { alert_the_merchants("rezzed"); }
84 }
85