Greeter Script on Landing
|
Samantha Sachertorte
Sexy Sam
Join date: 3 Sep 2005
Posts: 105
|
04-19-2006 10:50
Hi Can anyone help with a script that welcomes or greets someone who larrives n the main tp point on my land. But it will also, AUTO give a notecard to them. But I would like it to remeber who it gave a notecard to and not give them another one if they return to the land. Any help appreciated Had one but lost it Thanks Sam  )
_____________________
Owner of Sexy Sam's Designs Designs
|
Noland Brokken
Registered User
Join date: 6 Jul 2005
Posts: 6
|
Simple volume detect greeter
04-19-2006 19:34
My first attempt to post a script, I hope it works (the posting, I tested the script // VolDetect Notecard greeter // // Gives all notes in contents to new visitors and whispers a greeting. // List is pruned automatically, reset script to clear integer switch = 0; integer newlist = 0; key name; list name_list; // message whispered when new people arrive string GreetMsg = "Welcome to __your_location_here__!"; //- - - - - - - - - - - - - - - - integer isIn(list test_list, list test_item) // Looks for test_item { // in test_list integer i; // for (i = 0; i < llGetListLength(test_list); i++){ // if (llList2String(test_item, 0) == llList2String(test_list, i)) // return TRUE; if (llListFindList(test_list, test_item) != -1) return TRUE; // } return FALSE; } //- - - - - - - - - - - - - - - - default { state_entry() { llVolumeDetect(TRUE); newlist = FALSE; } changed(integer chg) { if (chg & CHANGED_INVENTORY) llResetScript(); } on_rez(integer r) { llResetScript(); } collision_start(integer total_number) { integer j; integer count = total_number; list dnames = []; string aname; for (j = 0; j < count; j++) { if (llDetectedType(j) & AGENT) { aname = llDetectedKey(j); if(aname != NULL_KEY) { // - KEYS now instead of names if (!isIn(name_list, (list)aname)) { name_list += (list)aname; newlist = TRUE; integer InvNum; string NoteName; integer NumCards = llGetInventoryNumber(INVENTORY_NOTECARD); for ( InvNum = 0; InvNum < NumCards; InvNum++) { NoteName = llGetInventoryName(INVENTORY_NOTECARD, InvNum); llGiveInventory(aname, NoteName); } } } } } if (newlist) { newlist = FALSE; llWhisper(0,GreetMsg); } while (llGetFreeMemory() < 512) { name_list = llList2List(name_list, 1, -1); } } }
------- Editted to add instructions... Put the script in an invisible prim that AVs will walk through/land in when arriving, this avoids any lag from sensors. Link extra prims on to increase the detection area.
|
Samantha Sachertorte
Sexy Sam
Join date: 3 Sep 2005
Posts: 105
|
Quick reply
04-19-2006 20:29
Perfect, works like a dream. Thank you Sam  )
_____________________
Owner of Sexy Sam's Designs Designs
|
Noland Brokken
Registered User
Join date: 6 Jul 2005
Posts: 6
|
Updated with dialog menu
04-21-2006 22:51
Just a couple useful bells and whistles added.... // message whispered when new people arrive string GreetMsg = "Welcome to __your_location_here__!"; string VisitText = "Most recent visitor: "; // diplays above w/name integer textname = TRUE; // displays last visitor overhead vector textcol = <1,1,0>; // in this color //-- Don't Change Below This unless you know what you're doing --\\ list MenuList = ["Silent", "Whisper", "Say", "Shout", "Stats", "List", "Clear", "0 Totals", "Test"]; integer volume = 1; //0:off 1:whisper 2:say 3:shout integer switch = 0; integer newlist = 0; integer menu_channel; integer menu_handler = 0; key data_request = NULL_KEY; key name; string MyName; string LastName; integer pcount; // count purged entries, might be dupes integer vcount; // running total of visitors not on list // reset script to clear list list name_list; //- - - - - - - - - - - - - - - - integer isIn(list test_list, list test_item) // Looks for test_item { // in test_list integer i; if (llListFindList(test_list, test_item) != -1) return TRUE; return FALSE; } //- - - - - - - - - - - - - - - - menu(key user,string title,list buttons) { // pick a channel and destroy it after 5 seconds // different channel at each use menu_channel = (integer)(llFrand(99999.0) * -1); if (menu_handler) { llSetTimerEvent(0.0); llListenRemove(menu_handler); } menu_handler = llListen(menu_channel,"",user,""); llDialog(user,title,buttons,menu_channel); llSetTimerEvent(15.0); } //-------------------------------------- giveallnotes(key who) { integer InvNum; string NoteName; integer NumCards = llGetInventoryNumber(INVENTORY_NOTECARD); for ( InvNum = 0; InvNum < NumCards; InvNum++) { NoteName = llGetInventoryName(INVENTORY_NOTECARD, InvNum); llGiveInventory(who, NoteName); } } default { state_entry() { llVolumeDetect(TRUE); newlist = FALSE; } changed(integer chg) { if (chg & CHANGED_INVENTORY) llResetScript(); } listen(integer ch, string nm, key id, string msg) { if (menu_handler) { llSetTimerEvent(0.0); llListenRemove(menu_handler); } if (msg == "List") { if (llGetListLength(name_list) > 0) { switch = 0; data_request = llRequestAgentData(llList2String(name_list, 0), DATA_NAME); } else llOwnerSay("List is empty."); } else if (msg == "Clear") { integer L = llGetListLength(name_list); pcount += L; name_list = []; llOwnerSay("List purged of " + (string)L + " entries."); } else if (msg == "Stats") { msg = "Visitors Greeted: " + (string)vcount; msg += ", On Current List: "; msg += (string)llGetListLength(name_list); msg += ", Purged: " + (string)pcount; msg += ", Memory Free: "; msg += (string)llGetFreeMemory(); llOwnerSay(msg); } else if (msg == "0 Totals") { pcount = 0; vcount = 0; llOwnerSay("Running totals reset."); } else if (msg == "Test") { llWhisper(0,GreetMsg); giveallnotes(llGetOwner()); } else if (msg == "Silent") { volume = 0; llOwnerSay(msg + " greeting mode set."); } else if (msg == "Whisper") { volume = 1; llOwnerSay(msg + " greeting mode set."); } else if (msg == "Say") { volume = 2; llOwnerSay(msg + " greeting mode set."); } else if (msg == "Shout") { volume = 3; llOwnerSay(msg + " greeting mode set."); } else if (msg == "Text On") { textname = TRUE; llOwnerSay("Float text enabled."); if (LastName != "") { llSetText(VisitText + LastName, textcol, 1.0); } } else if (msg == "Text Off") { textname = FALSE; llOwnerSay("Float text disabled"); llSetText("",<1,1,1>,1); } } collision_start(integer total_number) { integer j; integer count = total_number; list dnames = []; string aname; newlist = FALSE; for (j = 0; j < count; j++) { if (llDetectedType(j) & AGENT) { aname = llDetectedKey(j); if(aname != NULL_KEY) { // - KEYS now instead of names if (!isIn(name_list, (list)aname)) { if (!newlist) { if (volume == 1) llWhisper(0,GreetMsg); else if (volume == 2) llSay(0,GreetMsg); else if (volume == 3) llShout(0,GreetMsg); newlist = TRUE; } vcount++; name_list += (list)aname; giveallnotes(aname); } LastName = llKey2Name(aname); if (textname && (LastName != "")) { llSetText(VisitText + LastName, textcol, 1.0); } } } } while (llGetFreeMemory() < 512) { name_list = llList2List(name_list, 1, -1); pcount++; } } timer() // so the menu timeout and close its listener { llSetTimerEvent(0.0); if (menu_handler) { llListenRemove(menu_handler); llOwnerSay("Menu timed out, please click again to reactivate."); } } touch_start(integer n) { if (llDetectedKey(0) != llGetOwner()) return; list btn = MenuList; string msg = "Greeter Control Menu"; msg += "Greet volume is \""; msg += llList2String(MenuList, volume) + "\"."; btn += [llList2String(["Text On","Text Off"], textname)]; menu(llDetectedKey(0),msg,btn); } dataserver(key id, string data) { if (id != data_request) return; data_request = NULL_KEY; if (!switch) { MyName = llGetObjectName(); llOwnerSay("-----List has " + (string)llGetListLength(name_list) + " entries:"); llSetObjectName(""); } llOwnerSay("/me " + data); if (++switch < llGetListLength(name_list)) data_request = llRequestAgentData(llList2Key(name_list, switch), DATA_NAME); else { llSetObjectName(MyName); llOwnerSay("-----End of list."); } } }
Apologies for the fugly spaghetticode, but it seem to work. Noland
|
StrayDawg Switchblade
Registered User
Join date: 14 Jan 2006
Posts: 1
|
05-11-2006 05:52
Hey there, I have something similar, but I would like to know how to get the script to reset at say, midnight gametime, so if a person returns the next day, they get 'Notecard' again as a reminder. Can anyone help? Oh yea, I am very new to this, and the script I have in place is nowhere near as long as that above, it's only about 10-15 lines lol, but it works and I just want it to auto reset at midnight 
|
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
|
05-11-2006 06:09
A small warning here: sooner or later name_list will grow beyond the bounds of available memory (16k per script), and the script will crash. Because all SL names have different lengths, and I'm not sure how much space the bytecode would take and how efficient the list structure is, I can't say when this would happen but a guestimate maximum is about 1800 visitors, which is entirely possible if your area gets popular. Unfortunately, the luxury of "real life" programming - that is, knowing that there'll be plenty of memory and if there isn't there's always the swapfile - doesn't apply in LSL 
|
Anthony Hocken
Registered User
Join date: 16 Apr 2006
Posts: 121
|
05-13-2006 11:37
Could limit it to say the last 1000 visitors and maintain a pointer, then loop around back to the start of the list when you reach the 1001st visitor, overwritting the 1st visitor.
|
Wilan Deckard
Registered User
Join date: 22 Jun 2005
Posts: 7
|
06-08-2006 12:56
Or you could use the new httprequest function and store the list on your own system using some php script.
|
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
|
06-08-2006 13:02
...or use the w-hat httpdb service. That could be really helpful. w-hat.com/httpdb
|
Wilan Deckard
Registered User
Join date: 22 Jun 2005
Posts: 7
|
06-08-2006 13:06
That's gonna come in quite handy. Thanks for posting that, Keknehv.
|
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
|
Hmmm.....just doesn't look right
11-23-2007 10:49
Can someone take a quick look at this. Is this really building a list to compare the next avatar collision against? From: Noland Brokken My first attempt to post a script, I hope it works (the posting, I tested the script // VolDetect Notecard greeter // // Gives all notes in contents to new visitors and whispers a greeting. // List is pruned automatically, reset script to clear integer switch = 0; integer newlist = 0; key name; list name_list; // message whispered when new people arrive string GreetMsg = "Welcome to __your_location_here__!"; //- - - - - - - - - - - - - - - - integer isIn(list test_list, list test_item) // Looks for test_item { // in test_list integer i; // for (i = 0; i < llGetListLength(test_list); i++){ // if (llList2String(test_item, 0) == llList2String(test_list, i)) // return TRUE; if (llListFindList(test_list, test_item) != -1) return TRUE; // } return FALSE; } //- - - - - - - - - - - - - - - - default { state_entry() { llVolumeDetect(TRUE); newlist = FALSE; } changed(integer chg) { if (chg & CHANGED_INVENTORY) llResetScript(); } on_rez(integer r) { llResetScript(); } collision_start(integer total_number) { integer j; integer count = total_number; list dnames = []; string aname; for (j = 0; j < count; j++) { if (llDetectedType(j) & AGENT) { aname = llDetectedKey(j); if(aname != NULL_KEY) { // - KEYS now instead of names if (!isIn(name_list, (list)aname)) { name_list += (list)aname; newlist = TRUE; integer InvNum; string NoteName; integer NumCards = llGetInventoryNumber(INVENTORY_NOTECARD); for ( InvNum = 0; InvNum < NumCards; InvNum++) { NoteName = llGetInventoryName(INVENTORY_NOTECARD, InvNum); llGiveInventory(aname, NoteName); } } } } } if (newlist) { newlist = FALSE; llWhisper(0,GreetMsg); } while (llGetFreeMemory() < 512) { name_list = llList2List(name_list, 1, -1); } } }
------- Editted to add instructions... Put the script in an invisible prim that AVs will walk through/land in when arriving, this avoids any lag from sensors. Link extra prims on to increase the detection area.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
11-23-2007 20:46
From: StrayDawg Switchblade Hey there, I have something similar, but I would like to know how to get the script to reset at say, midnight gametime, so if a person returns the next day, they get 'Notecard' again as a reminder. Can anyone help? Oh yea, I am very new to this, and the script I have in place is nowhere near as long as that above, it's only about 10-15 lines lol, but it works and I just want it to auto reset at midnight  throw in a timer event that checks llGetGMTclock every 30-60 minutes, if it's smaller than the last check (or below a certain threshold), clear the list...
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Nazz Niven
Registered User
Join date: 11 Jan 2007
Posts: 9
|
01-24-2008 01:26
Ok..I'm not a scripter just FYI. I been looking for this script and tried both versions listed in this thread...somehow...only i got the notecard...other people around me didnt get it. I tried to reset and still didnt get any. Is there something i did wrong? Can someone help me out please?
|