Difference between revisions of "Collision message sender"

From Second Life Wiki
Jump to navigation Jump to search
m (-1 >> ERR_GENERIC and 0 >> PUBLIC_CHANNEL)
Line 9: Line 9:




string message = " Merry Christmas ";   // put your message here.
string message = " Merry Christmas ";                   // put your message here.
list users;
list users;
string user;
string user;
default
default
{
{
    state_entry()
     collision_start(integer num_detected)               // check for an avatar colliding with the prim.
    {
       
    }
 
     collision_start(integer num_detected)   // check for an avatar colliding with the prim.
     {
     {
         user = llDetectedName(0);
         user = llDetectedName(0);
         if (llListFindList(users,[user]) == -1)// look at the list, if the name is not there,
         if (llListFindList(users,[user]) == ERR_GENERIC) // look at the list, if the name is not there,
         {
         {
             llSay(0, message + user);      // send the message to the detected avatar.
             llSay(PUBLIC_CHANNEL, message + user);      // send the message to the detected avatar.
             users += user;                 // add the users name to a list so they only get the message once.
             users += user;                               // add the users name to a list so they only get the message once.
             llSetTimerEvent(0);             // reset and restart the timer to 10 minutes
             llSetTimerEvent(0.0);                       // reset and restart the timer to 10 minutes
             llSetTimerEvent(600);           // change the number for the number of seconds before clearing the list.
             llSetTimerEvent(600);                       // change the number for the number of seconds before clearing the list.
         }
         }
     }
     }
     timer()
     timer()
     {
     {
         llSetTimerEvent(0);                 // turn the timer off
         llSetTimerEvent(0.0);                           // turn the timer off
         users = [];                         // clear the list
         users = [];                                     // clear the list
     }
     }
}
}

Revision as of 01:52, 8 October 2013

Receiving a message every time that you step on a prim is annoying, so this script uses a short name store to check that the avatar has not been sent the message for at least 10 minutes. As an avatar stands on or hits against the prim, the timer is reset to a further 10 minutes, at the end of the timer period, the name list is cleared.

<lsl>

// The script written by Taff Nouvelle. // Use it in any way that you want // but please leave this header intact.


string message = " Merry Christmas "; // put your message here. list users; string user; default {

   collision_start(integer num_detected)                // check for an avatar colliding with the prim.
   {
       user = llDetectedName(0);
       if (llListFindList(users,[user]) == ERR_GENERIC) // look at the list, if the name is not there,
       {
           llSay(PUBLIC_CHANNEL, message + user);       // send the message to the detected avatar.
           users += user;                               // add the users name to a list so they only get the message once.
           llSetTimerEvent(0.0);                        // reset and restart the timer to 10 minutes
           llSetTimerEvent(600);                        // change the number for the number of seconds before clearing the list.
       }
   }
   timer()
   {
       llSetTimerEvent(0.0);                            // turn the timer off
       users = [];                                      // clear the list
   }

}