Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define NAVY <0.000, 0.122, 0.247>
- #define BLUE <0.000, 0.455, 0.851>
- #define AQUA <0.498, 0.859, 1.000>
- #define TEAL <0.224, 0.800, 0.800>
- #define OLIVE <0.239, 0.600, 0.439>
- #define GREEN <0.180, 0.800, 0.251>
- #define LIME <0.004, 1.000, 0.439>
- #define YELLOW <1.000, 0.863, 0.000>
- #define ORANGE <1.000, 0.522, 0.106>
- #define RED <1.000, 0.255, 0.212>
- #define MAROON <0.522, 0.078, 0.294>
- #define FUCHSIA <0.941, 0.071, 0.745>
- #define PURPLE <0.694, 0.051, 0.788>
- #define WHITE <1.000, 1.000, 1.000>
- #define SILVER <0.867, 0.867, 0.867>
- #define GRAY <0.667, 0.667, 0.667>
- #define BLACK <0.067, 0.067, 0.067>
- key notecardQueryId;
- string notecardName = "Bot List";
- integer notecardLine;
- list namesKeySet;
- string botName;
- integer totalNotcardLines;
- key totalNotecardQyID;
- key name_key_query;
- integer dListen_handle;
- integer dListen_channel;
- //list dataSetKeys;
- key botStatusQy;
- integer botOnline;
- integer botOffline;
- integer i;
- // default Bantime is set to 24 hours
- float defBanTime = 24;
- // default scantime is set to 10 minutes
- integer scanTime = 600;
- key user;
- // Resets the banTime and updates the online status
- resetBanTime(float banTime)
- {
- defBanTime = banTime;
- string bTime = "Setting Ban Time to ";
- integer x;
- if(banTime == 0.500000) bTime += "30 Minutes.";
- if(banTime == 1) bTime += "1 Hour.";
- if(banTime == 2) bTime += "2 Hours.";
- if(banTime == 6) bTime += "6 Hours.";
- if(banTime == 24) bTime += "1 Day.";
- if(banTime == 168) bTime += "1 Week.";
- if(banTime == 0) bTime += "Forever.";
- llSay(0, bTime);
- i = 0;
- botOnline = 0;
- botOffline = 0;
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(i, 1),0), DATA_ONLINE);
- }
- // Convert Unix Time to SLT, identifying whether it is currently PST or PDT (i.e. Daylight Saving aware)
- // Omei Qunhua December 2013
- list weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
- string Unix2PST_PDT(integer insecs)
- {
- string str = Convert(insecs - (3600 * 8) ); // PST is 8 hours behind GMT
- if (llGetSubString(str, -3, -1) == "PDT") // if the result indicates Daylight Saving Time ...
- str = Convert(insecs - (3600 * 7) ); // ... Recompute at 1 hour later
- return str;
- }
- // This leap year test is correct for all years from 1901 to 2099 and hence is quite adequate for Unix Time computations
- integer LeapYear(integer year)
- {
- return !(year & 3);
- }
- integer DaysPerMonth(integer year, integer month)
- {
- if (month == 2) return 28 + LeapYear(year);
- return 30 + ( (month + (month > 7) ) & 1); // Odd months up to July, and even months after July, have 31 days
- }
- string Convert(integer insecs)
- {
- integer w; integer month; integer daysinyear;
- integer mins = insecs / 60;
- integer secs = insecs % 60;
- integer hours = mins / 60;
- mins = mins % 60;
- integer days = hours / 24;
- hours = hours % 24;
- integer DayOfWeek = (days + 4) % 7; // 0=Sun thru 6=Sat
- integer years = 1970 + 4 * (days / 1461);
- days = days % 1461; // number of days into a 4-year cycle
- @loop;
- daysinyear = 365 + LeapYear(years);
- if (days >= daysinyear)
- {
- days -= daysinyear;
- ++years;
- jump loop;
- }
- ++days;
- for (w = month = 0; days > w; )
- {
- days -= w;
- w = DaysPerMonth(years, ++month);
- }
- string str = ((string) years + "-" + llGetSubString ("0" + (string) month, -2, -1) + "-" + llGetSubString ("0" + (string) days, -2, -1) + " " +
- llGetSubString ("0" + (string) hours, -2, -1) + ":" + llGetSubString ("0" + (string) mins, -2, -1) );
- integer LastSunday = days - DayOfWeek;
- string PST_PDT = " PST"; // start by assuming Pacific Standard Time
- // Up to 2006, PDT is from the first Sunday in April to the last Sunday in October
- // After 2006, PDT is from the 2nd Sunday in March to the first Sunday in November
- if (years > 2006 && month == 3 && LastSunday > 7) PST_PDT = " PDT";
- if (month > 3) PST_PDT = " PDT";
- if (month > 10) PST_PDT = " PST";
- if (years < 2007 && month == 10 && LastSunday > 24) PST_PDT = " PST";
- return (llList2String(weekdays, DayOfWeek) + " " + str + PST_PDT);
- }
- // lists out to the user bots stored in linksetdata and the ban time
- listLinksetData()
- {
- integer x;
- list keyEntry;
- string botStatus;
- for(x = 0; x < llLinksetDataCountKeys(); x++)
- {
- keyEntry = llCSV2List((string) llLinksetDataRead((string) llLinksetDataListKeys(x, 1)));
- if(llList2Integer(keyEntry, 1) == 0)
- botStatus = " is Offline.";
- else
- {
- botStatus = " was banned on " + Unix2PST_PDT(llList2Integer(keyEntry, 1));
- }
- llRegionSayTo(user, 0, llList2String(keyEntry, 0) + botStatus);
- }
- }
- // lists out the bots that are banned and when they where banned.
- listLinksetBanned()
- {
- integer x;
- list keyEntry;
- string botStatus;
- for(x = 0; x < llLinksetDataCountKeys(); x++)
- {
- keyEntry = llCSV2List((string) llLinksetDataRead((string) llLinksetDataListKeys(x, 1)));
- if(llList2Integer(keyEntry, 1) > 0)
- {
- botStatus = " was banned on " + Unix2PST_PDT(llList2Integer(keyEntry, 1));
- llRegionSayTo(user, 0, llList2String(keyEntry, 0) + botStatus);
- }
- }
- }
- // search the keys in a linksetdata for a string, needle
- list linkSetSearch(string rexgep, string needle)
- {
- list results;
- integer x;
- if(rexgep == "")
- rexgep = ".*";
- list search = llLinksetDataFindKeys(rexgep, 0, 0);
- for(x = -llGetListLength(search); x < 0; ++x)
- {
- if(!llSubStringIndex(llLinksetDataRead(llList2String(search, x)), needle))
- results += llList2String(search, x);
- }
- return results;
- }
- // load the notecard of bots in to linksetData storage
- default
- {
- state_entry()
- {
- llSetText("", <0,0,0>, 0);
- state bot_status;
- if(llGetLandOwnerAt(llGetPos()) != llGetOwner() && llLinksetDataRead("testmode") == "")
- {
- llOwnerSay("Device neends to be Deeded to group to operate correctly.");
- llSetColor(<1.000, 1.000, 1.000>, ALL_SIDES);
- return;
- }
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<0.694, 0.051, 0.788>, ALL_SIDES);
- }
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- totalNotecardQyID = llGetNumberOfNotecardLines(notecardName);
- }
- touch_start(integer start)
- {
- llResetTime();
- }
- touch_end(integer end)
- {
- if(llGetTime() > 2)
- {
- if(llLinksetDataRead("testmode"))
- llLinksetDataDelete("testmode");
- else
- llLinksetDataWrite("testmode", "true");
- llResetScript();
- }
- }
- dataserver(key requested, string data)
- {
- if(requested == totalNotecardQyID)
- {
- totalNotcardLines = (integer) data;
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- }
- if(requested == name_key_query)
- {
- if(llLinksetDataRead(data) == "")
- {
- llLinksetDataWrite(data, botName + ",0");
- //llOwnerSay("Adding "+ botName +" ("+ (string) data + ")");
- }
- else
- {
- //llSay(0, "Skipping " + botName + " ("+(string) data + ")");
- }
- llSleep(0.3);
- notecardQueryId = llGetNotecardLine(notecardName, ++notecardLine);
- }
- if(notecardQueryId == requested)
- {
- if(data == EOF)
- {
- llSay(0, "Cardlines Read: " + (string) notecardLine);
- llSay(0, "Keys in LinksetData: " + (string) llLinksetDataCountKeys());
- state bot_status;
- }
- else
- {
- botName = llStringTrim(data, STRING_TRIM);
- name_key_query = llRequestUserKey(botName);
- }
- }
- llSetText("Loading\n \n" + (string) notecardLine +"/"+ (string) totalNotcardLines+ "\n" +
- (string) llLinksetDataAvailable() + "\n",
- <1,0,1>, 1.0);
- }
- listen(integer chan, string name, key id, string msg)
- {
- if(chan == dListen_channel)
- {
- llSetTimerEvent(0);
- llListenRemove(dListen_handle);
- if(msg == "Reload")
- {
- llLinksetDataReset();
- totalNotecardQyID = llGetNumberOfNotecardLines(notecardName);
- notecardLine = 0;
- }
- if(msg == "Diff")
- {
- state diff;
- }
- }
- }
- timer()
- {
- llListenRemove(dListen_handle);
- llSetTimerEvent(0);
- }
- changed(integer change)
- {
- if(change & CHANGED_INVENTORY)
- {
- llSay(0, "Inventory Changed, resetting.");
- llResetScript();
- } else if(change & CHANGED_OWNER)
- {
- llResetScript();
- }
- }
- }
- state diff
- {
- state_entry()
- {
- llSay(0, "state entry");
- }
- }
- state bot_status
- {
- state_entry()
- {
- llSay(0, (string) llGetFreeMemory());
- i = 0;
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<1.000, 0.255, 0.212>, ALL_SIDES);
- }
- //dataSetKeys = llLinksetDataListKeys(0, -1);
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- llListen(dListen_channel, "", "", "");
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(i, 1),0), DATA_ONLINE);
- }
- touch_end(integer num)
- {
- user = llDetectedKey(0);
- llDialog(user, "Main Menu", ["LinkSet", "Setup"], dListen_channel);
- }
- listen(integer chan, string name, key id, string msg)
- {
- if(chan == dListen_channel)
- {
- if(msg == "Reload")
- {
- state default;
- }
- if(msg == "Diff")
- {
- state diff;
- }
- if(msg == "LinkSet")
- llDialog(user, "Linkset Data", ["List All", "List Banned", "Clear"], dListen_channel);
- if(msg == "List All")
- listLinksetData();
- if(msg == "List Banned")
- listLinksetBanned();
- if(msg == "Clear")
- state listLinksetClear;
- if(msg == "Setup")
- llDialog(user, "Select and option for Setup", ["Bantime", "Scantime"], dListen_channel);
- if(msg == "Scantime")
- {
- llDialog(user, "Select a scantime.",
- [ "1 Hour", "2 Hours", "5 Minutes", "10 Minutes", "30 Minutes" ],
- dListen_channel);
- }
- if(msg == "Bantime")
- {
- string bTime = "Set Bantime. Currently set to ";
- if(defBanTime == 0.500000) bTime += "30 Minutes.";
- if(defBanTime == 1) bTime += "1 Hour.";
- if(defBanTime == 2) bTime += "2 Hours.";
- if(defBanTime == 6) bTime += "6 Hours.";
- if(defBanTime == 24) bTime += "1 Day.";
- if(defBanTime == 168) bTime += "1 Week.";
- if(defBanTime == 0) bTime += "Forever.";
- llDialog(user, bTime,
- [ "6 Hours", "1 Day", "1 Week", "30 mins", "1 Hour", "2 Hours" , "Forever"],
- dListen_channel);
- }
- if(msg == "30 mins") resetBanTime(0.5);
- if(msg == "1 Hour") resetBanTime(1);
- if(msg == "2 Hours") resetBanTime(2);
- if(msg == "6 Hours") resetBanTime(6);
- if(msg == "1 Day") resetBanTime(24);
- if(msg == "1 Week") resetBanTime(168);
- if(msg == "Forever") resetBanTime(0);
- }
- }
- changed(integer change)
- {
- if(change & CHANGED_INVENTORY)
- {
- llSay(0, "Inventory Changed, resetting.");
- llResetScript();
- } else if(change & CHANGED_OWNER)
- {
- llResetScript();
- }
- }
- timer()
- {
- botOnline = 0;
- botOffline = 0;
- i = 0;
- if(llLinksetDataRead("testmode"))
- {
- llSay(999, "STOP");
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- }
- else
- {
- llSay(888, "STOP");
- llSetColor(<1.000, 0.255, 0.212>, ALL_SIDES);
- }
- //dataSetKeys = llLinksetDataListKeys(0, -1);
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(i, 1), 0), DATA_ONLINE);
- }
- dataserver(key queryid, string data)
- {
- list keyBotStat;
- if(queryid == botStatusQy)
- {
- llSetTimerEvent(0);
- keyBotStat = llCSV2List(llLinksetDataRead(llList2String(llLinksetDataListKeys(i, 1), 0)));
- if(data == (string) TRUE)
- {
- if(llList2Integer(keyBotStat, 1) == 0)
- {
- llLinksetDataWrite(llList2String(llLinksetDataListKeys(i, 1), 0), llList2String(keyBotStat, 0) +
- "," + (string) llGetUnixTime());
- llWhisper(0, (string) llLinksetDataListKeys(i, 1) +
- " Banning :" + llList2String(keyBotStat, 0));
- llAddToLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0), defBanTime);
- }else if(llList2Integer(keyBotStat, 1) > 0)
- {
- llLinksetDataWrite(llList2String(llLinksetDataListKeys(i, 1), 0), llList2String(keyBotStat, 0) +
- "," + (string) llGetUnixTime());
- llRemoveFromLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0));
- llSleep(2.0);
- llAddToLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0), defBanTime);
- }
- ++botOnline;
- } else if(data == (string) FALSE)
- {
- if(llList2Integer(keyBotStat,1) > 0)
- {
- llLinksetDataWrite(llList2String(llLinksetDataListKeys(i, 1), 0),
- llList2String(keyBotStat, 0) + ",0");
- llRemoveFromLandBanList(llList2Key(llLinksetDataListKeys(i, 1), 0));
- }
- ++botOffline;
- }
- }
- //llSay(0, llLinksetDataRead(llList2Key(dataSetKeys, i)));
- if(i < llLinksetDataCountKeys())
- {
- botStatusQy = llRequestAgentData(llList2Key(llLinksetDataListKeys(++i, 1), 0), DATA_ONLINE);
- } else
- {
- if(llLinksetDataRead("testmode"))
- {
- llSetColor(<0.000, 0.455, 0.851>, ALL_SIDES);
- llSay(999, "START");
- }
- else
- {
- llSay(888, "START");
- llSetColor(<0.004, 1.000, 0.439>, ALL_SIDES);
- }
- llSetTimerEvent(scanTime);
- }
- llSetText("Known Bots: " + (string) llLinksetDataCountKeys() + "\n" +
- "Bots Online : " + (string) botOnline + "\n" +
- "Bots Offline : " + (string) botOffline + "\n" +
- (string) llLinksetDataAvailable() + "\n" +
- (string) llGetFreeMemory(),
- <0,1,1>, 1);
- }
- }
- state listLinksetClear
- {
- state_entry()
- {
- notecardLine = 0;
- dListen_channel = 0x80000000 | (integer)llFrand(65536) | ((integer)llFrand(65536) << 16);
- llListen(dListen_channel, "", "", "");
- llDialog(user, "This Delete All Bots in Memory. It will not remove them from land banlist.\nProceed?",
- ["Yes", "No"], dListen_channel);
- }
- listen(integer chan, string name, key id, string msg)
- {
- if(msg == "Yes")
- {
- llSay(0, "Removing Bot Keys from Memory.");
- notecardQueryId = llGetNotecardLine(notecardName, notecardLine);
- }
- }
- dataserver(key requested, string data)
- {
- if(notecardQueryId == requested)
- {
- if(data == EOF)
- {
- llSay(0, "All bot memory is clear. Going dormant. Touch to reset and reload.");
- state resting;
- }
- else
- {
- botName = llStringTrim(data, STRING_TRIM);
- list botList = linkSetSearch("", botName);
- llSay(0, (string) notecardLine +") " + llList2String(botList, 0));
- llLinksetDataDelete(llList2String(botList, 0));
- llSetText((string) llLinksetDataCountKeys() + "\n" +
- (string) llGetFreeMemory() , <1,0.5,1>, 1.0);
- notecardQueryId = llGetNotecardLine(notecardName, ++notecardLine);
- }
- }
- }
- }
- state resting
- {
- state_entry()
- {
- llSetText("Touch to Reset", <1.000, 0.863, 0.000>, 1.0);
- llSetColor(<0.067, 0.067, 0.067>, ALL_SIDES);
- }
- touch_end(integer end)
- {
- llResetScript();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement