/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2011 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// list sList = []; list nList = []; list aList = []; list pList = []; key sQuery = NULL_KEY; key aQuery = NULL_KEY; integer sLine = 0; integer aLine = 0; integer comHandle = 0; readSetup() { aList = []; sList = []; nList = []; integer cards = 0; integer i = llGetInventoryNumber(INVENTORY_NOTECARD)-1; do { if(llGetInventoryName(INVENTORY_NOTECARD, i) == "Subscribers" || llGetInventoryName(INVENTORY_NOTECARD, i) == "Access") ++cards; if(cards == 2) jump found_cards; } while(--i>-1); return; @found_cards; sLine = 0; aLine = 0; sQuery = llGetNotecardLine("Subscribers", sLine); aQuery = llGetNotecardLine("Access", aLine); } readPost() { pList = []; integer i = llGetInventoryNumber(INVENTORY_ALL)-1; do { if(llGetInventoryName(INVENTORY_ALL, i) == "Subscribers") jump continue; if(llGetInventoryName(INVENTORY_ALL, i) == "Access") jump continue; if(llGetInventoryName(INVENTORY_ALL, i) == llGetScriptName()) jump continue; pList += llGetInventoryName(INVENTORY_ALL, i); @continue; } while(--i>-1); } sendPost(key id) { integer i = llGetListLength(sList)-1; do { llInstantMessage(llList2Key(sList, i), "Hello " + llList2String(nList, i) + "! We have a delivery for you, a package containing " + llDumpList2String(pList, ", ") + ". Please accept the items as they are being delivered..."); integer j = 0; do { llGiveInventory(llList2Key(sList, i), llList2String(pList, j)); llInstantMessage(id, "Sending: " + llList2String(pList, j) + " to " + llList2String(nList, i)); } while(--j>-1); llInstantMessage(llList2Key(sList, i), "Have a nice day " + llList2String(nList, i) + "! Thank you for subscribing with us."); } while(--i>-1); } default { state_entry() { readSetup(); readPost(); } changed(integer change) { if(change & CHANGED_INVENTORY) llResetScript(); } touch_start(integer total_number) { if(llListFindList(aList, (list)llDetectedName(0)) == -1) return; integer comChannel = ((integer)("0x"+llGetSubString((string)llGetKey(),-8,-1)) & 0x3FFFFFFF) ^ 0xBFFFFFFF; comHandle = llListen(comChannel, "", llDetectedKey(0), ""); llDialog(llDetectedKey(0), "Welcome to the mailer, please select an action: ", [ "Mail!", "Subs" ], comChannel); } listen(integer channel, string name, key id, string message) { if(llListFindList(aList, (list)name) == -1) return; if(message == "Mail!") { string post = ""; integer i = llGetListLength(pList) -1; do { post += (string)i + ".) " + llList2String(pList, i) + "\n"; } while(--i>-1); llDialog(id, "Please confirm sending the following items to all the listed subscribers:\n" + post, [ "Confirm", "Abort" ], channel); return; } if(message == "Subs") { string subs; integer j = llGetListLength(nList)-1; do { subs += llList2String(nList, j); if(j+1-1); llInstantMessage(id, "Your subscribers are: " + subs); } if(message == "Confirm") { sendPost(id); } llListenRemove(comHandle); } dataserver(key query_id, string data) { if(query_id == aQuery) { if(data == EOF) return; if(data == "") jump next_access; aList += (list) data; @next_access; aQuery = llGetNotecardLine("Access", ++aLine); } if(query_id == sQuery) { if(data == EOF) return; if(data == "") jump next_subscriber; sList += llList2List(llParseString2List(data, ["#"], [""]), 0, 0); nList += llList2List(llParseString2List(data, ["#"], [""]), 1, 1); @next_subscriber; sQuery = llGetNotecardLine("Subscribers", ++sLine); } } }