This script reads agents from a notecard and announces the online / offline status of agents.
agents
and list all agents names line-by-line along with their keys, separated by a hash sign:Morgan LeFay#2af23607-a672-476d-a5e3-16327d0102bf Annika Hansen#99999999-9999-9999-9999-999999999997
agents
notecard in it.
The script will tell you: Notecard read, waiting for events…
when the script has begun the sweep. That is an indication that the script has started to sweep the list of agents you provided. You will see no changes and no other messages until an agent changes status.
To make the same script send an e-mail once an agent goes on- or offline, edit the script to insert the line:
llEmail("some@email.com", "[WaS] Online Detector", name + " is offline");
after:
if(data == "0" && on == 1) {
and
llEmail("some@email.com", "[WaS] Online Detector", name + " is online");
after:
if(data == "1" && on == 0) {
and change some@email.com
to a valid e-mail.
/////////////////////////////////////////////////////////////////////////// // Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 // // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // // rights of fair usage, the disclaimer and warranty conditions. // /////////////////////////////////////////////////////////////////////////// key nQuery = NULL_KEY; integer nLine = 0; list nList = []; list oList = []; integer cursor = 0; default { state_entry() { integer i = llGetInventoryNumber(INVENTORY_NOTECARD)-1; do { if(llGetInventoryName(INVENTORY_NOTECARD, i) == "agents") jump found_notecard; } while(--i>-1); llSay(DEBUG_CHANNEL, "Could not find agents notecard."); return; @found_notecard; nQuery = llGetNotecardLine("agents", nLine); } changed(integer change) { if(change & CHANGED_INVENTORY) llResetScript(); } dataserver(key id, string data) { if(id != nQuery) return; if(data == EOF) state scan; if(data == "") jump next_line; nList += data; oList += 0; @next_line; nQuery = llGetNotecardLine("agents", ++nLine); } } state scan { state_entry() { llRequestAgentData(llList2Key(llParseString2List(llList2String(nList, cursor), ["#"], []), 1), DATA_ONLINE); } dataserver(key id, string data) { string name = llList2String(llParseString2List(llList2String(nList, cursor), ["#"], []), 0); integer online = llList2Integer(oList, cursor); if(data == "0" && online == 1) { llInstantMessage(llGetOwner(), name + " is offline."); oList = llListReplaceList(oList, (list)0, cursor, cursor); jump next; } if(data == "1" && online == 0) { llInstantMessage(llGetOwner(), name + " is online."); oList = llListReplaceList(oList, (list)1, cursor, cursor); jump next; } @next; if(++cursor > llGetListLength(nList)-1) cursor = 0; llRequestAgentData(llList2Key(llParseString2List(llList2String(nList, cursor), ["#"], []), 1), DATA_ONLINE); } changed(integer change) { if(change & CHANGED_INVENTORY) llResetScript(); } }