// Login Greeter script // Provides a record for your chat log of your logging in and out, // and at what times this occurs. // Ordinal Malaprop // 2007-03-11 integer gOnline = TRUE; key gOwner = NULL_KEY; string gOwnerName = ""; string gLast = ""; string prettystamp() { // Return the date and time in a more readable format list stamp = llParseString2List(llGetTimestamp(), ["T", ":"], []); return llList2String(stamp, 0) + " " + llList2String(stamp, 1) + ":" + llList2String(stamp, 2); } default { state_entry() { // Put in a reminder of what the object actually is llSetText(llGetObjectName(), <1.0, 0.9, 1.0>, 1.0); // Set the owner's key at the start gOwner = llGetOwner(); // Take only first name to use in greetings // We use llKey2Name, assuming that the owner is actually here at the start gOwnerName = llKey2Name(gOwner); gOwnerName = llGetSubString(gOwnerName, 0, llSubStringIndex(gOwnerName, " ") - 1); // Set "time you were last here" to the current time gLast = prettystamp(); // ...and set everything going llOwnerSay("Hello " + gOwnerName + "! It is now " + gLast); llSetTimerEvent(60.0); } changed(integer change) { // If the owner changes, reset the whole lot if (change & CHANGED_OWNER) llResetScript(); } timer() { // Every minute, check whether the owner is online or not llRequestAgentData(llGetOwner(), DATA_ONLINE); } dataserver(key query, string data) { integer online = (integer)data; // Was there a change in online status? if (online != gOnline) { if (online) { // Just logged in - send a reminder // IMs from objects appear in general chat log llInstantMessage(gOwner, "Hello " + gOwnerName + ", welcome back! You were last here at " + gLast + " and the time is now " + prettystamp()); } else { // Just logged out - set the "last here at" variable gLast = prettystamp(); } // Then set the general online flag to the current value gOnline = online; } } }