User:Cow Taurog/Visitor nagger

From Second Life Wiki
Jump to navigation Jump to search

This script is used to nag new visitors with rules, a greeting, MOTD, or the like. Drop a notecard named Rules, followed by this script into any object. The range is 20m, and it scans for people within range every 10 seconds by default. If someone is found that hasn't already been nagged, it will IM them the contents of the notecard. There isn't a way to save the list of people that have already been nagged, and if the script is reset, everyone will be nagged again. <lsl> // This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License // http://creativecommons.org/licenses/by-sa/3.0/ // Commercial use is allowed. // Modification and/or distribution is allowed, as long as attribution is given, and the same license is used. // list glLines; string gsNotecard="Rules"; float gfPoll=10; float gfRange=20; list glKeys; key gkReq; integer i; default{

   state_entry(){
       gkReq=llGetNotecardLine(gsNotecard,i);
   }
   dataserver(key req,string mess){if(req==gkReq){
       glLines=glLines+[mess];
       i++;
       gkReq=llGetNotecardLine(gsNotecard,i);
       if(mess==EOF){state running;}
   }}

} state running{

   state_entry(){
       llOwnerSay("'"+gsNotecard+"' notecard loaded.");
       llSensorRepeat("","",AGENT,gfRange,PI,gfPoll);
   }
   sensor(integer num){for(i=0;i<num;i++){
       if(llListFindList(glKeys,[llDetectedKey(i)])==-1){
           glKeys=glKeys+[llDetectedKey(i)];
           llInstantMessage(llDetectedKey(i),"\n"+llDumpList2String(glLines,"\n"));
       }
   }}

} </lsl>