LSL greeter script: welcome message for visitors
Free LSL visitor greeter for Second Life stores and clubs: a private welcome message once a day for each visitor who comes near, no spam in local chat.
Say hello to every visitor without being online. This greeter script notices avatars that come near and sends each one a private welcome message, once a day. Only the visitor sees it, so local chat stays quiet, and the owner is never greeted.
// Visitor Greeter - free LSL script from WhatSL (https://whatsl.com/scripts/lsl-greeter-script)
// Free to use, change and put in your own creations, also ones you sell.
//
// Sends a private welcome message to each visitor who comes near, once a day.
// Only the visitor sees it, so it does not spam local chat. The owner is never greeted.
string WELCOME_TEXT = "Welcome, %name%! Have a look around and grab the free gift at the entrance.";
float RANGE_METRES = 20.0; // how close a visitor must come (up to 96.0)
float SCAN_SECONDS = 10.0; // how often to look for new visitors
integer MAX_REMEMBER = 300; // visitors remembered per day
list gSeen = [];
integer gDay;
string fillName(string s, string name)
{
integer i = llSubStringIndex(s, "%name%");
if (i == -1) return s;
return llInsertString(llDeleteSubString(s, i, i + 5), i, name);
}
default
{
state_entry()
{
gDay = llGetUnixTime() / 86400;
llSensorRepeat("", NULL_KEY, AGENT, RANGE_METRES, PI, SCAN_SECONDS);
}
on_rez(integer param)
{
llResetScript();
}
sensor(integer total)
{
integer today = llGetUnixTime() / 86400;
if (today != gDay)
{
gDay = today;
gSeen = [];
}
key owner = llGetOwner();
integer i;
for (i = 0; i < total; ++i)
{
key av = llDetectedKey(i);
if (av != owner)
{
if (llListFindList(gSeen, [av]) == -1)
{
llRegionSayTo(av, 0, fillName(WELCOME_TEXT, llGetDisplayName(av)));
gSeen += [av];
if (llGetListLength(gSeen) > MAX_REMEMBER) gSeen = llDeleteSubList(gSeen, 0, 0);
}
}
}
}
}
Free to use, change and put in your own creations, also ones you sell.
How to set it up
- Put the script in a small object near your landing point, such as a sign or an invisible prim.
- Write your message in WELCOME_TEXT. %name% becomes the visitor's display name.
- Save. Walk away, come back on another avatar or ask a friend to test it.
Settings
- WELCOME_TEXT: the welcome message. Mention what is new, where the gift is, or your group.
- RANGE_METRES: how close a visitor must come, up to 96 metres.
- SCAN_SECONDS: how often the greeter looks for new visitors. 10 seconds is a good balance.
- MAX_REMEMBER: how many visitors it remembers per day before it starts forgetting the oldest.
Tips
- Keep the message short and friendly; one or two sentences.
- Put one greeter near the landing point rather than several around the store, so visitors get one message.
Frequently asked questions
Do visitors get the message every time they come?
No. Each visitor is greeted once per day (by the server's UTC date).
Does the greeter store who visited?
It only keeps the keys of today's visitors in memory to avoid greeting twice, and forgets them the next day or when the script restarts.
Does the greeter cause lag?
A sensor every 10 seconds is light. Avoid scanning every second or using very many greeters on one region.