Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Automatic notecard giver script & postbox script

Benz Bingyi
Registered User
Join date: 21 May 2007
Posts: 48
05-23-2007 22:32
Hello everybody.

I looked and tried to write it myself but i failed so now i want to ask foe your help.
Does somebody has a automatic notecard giver script so that people who land at my landingspot automaticly get a notecard.
I also looking for a mailbox script where people can drop there notecards in.
Thank you for helping me.

Greetings Benz Bingyi

I found the mailbox script..it was on the sl website..did look good enough...sorry

default
{
state_entry()
{
llAllowInventoryDrop(TRUE);
llSay(0, "Please drop your notecard here by dragging it into the box from your inventory.";);
}
changed(integer mask)
{
if(mask & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
llWhisper(0, "Thank you for submitting your notecard!!!";);
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-24-2007 00:42
From: Benz Bingyi
Hello everybody.

I looked and tried to write it myself but i failed so now i want to ask foe your help.
Does somebody has a automatic notecard giver script so that people who land at my landingspot automaticly get a notecard.
I also looking for a mailbox script where people can drop there notecards in.
Thank you for helping me.

Greetings Benz Bingyi


Covered numerous times in this forum.
Try this one
_____________________
I'm back......
Benz Bingyi
Registered User
Join date: 21 May 2007
Posts: 48
05-24-2007 01:35
Thanks for your reply but this is a script that does not give it automaticly you have to touch an object before it gives the notecard.
I'm looking for a script with sensor that automaticly gives a notecard when somebody lands on my tp spot our land whitout touching an object first.

Thank you
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-24-2007 02:27
From: Benz Bingyi
Thanks for your reply but this is a script that does not give it automaticly you have to touch an object before it gives the notecard.
I'm looking for a script with sensor that automaticly gives a notecard when somebody lands on my tp spot our land whitout touching an object first.

Thank you


Sorry i thought you would be able to adapt it easy enough.
You dont need a sensor, use a volume detect prim instead just swap the touch_start event handler for a collision_start one i.e.

CODE

default
{
state_entry()
{
llVolumeDetect(TRUE);
}

collision_start(integer total_number)
{
if (llGetInventoryNumber(INVENTORY_NOTECARD) > 0)
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_NOTECARD, 0));
}
if (llGetInventoryNumber(INVENTORY_SOUND) > 0)
{
llTriggerSound(llGetInventoryName(INVENTORY_SOUND, 0), 1.0);
}
}
}


The complication will be if you want to ensure that you only give the noetcard once to each person.
_____________________
I'm back......
Benz Bingyi
Registered User
Join date: 21 May 2007
Posts: 48
05-24-2007 07:14
Thanks again.

I thought if this script to,but yes like you said i want to ensure that the notecard only will be recieved once very time someone is on my parcel and not everytime he or she comes in contact with the collision prim.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-24-2007 08:23
From: Benz Bingyi
Thanks again.

I thought if this script to,but yes like you said i want to ensure that the notecard only will be recieved once very time someone is on my parcel and not everytime he or she comes in contact with the collision prim.


Well everytime they come on your land may be a bit of a tall order but we can limit it to ensure its not too often (depending upon how many visitors you are expecting) by keeping a list of recent visitors in the exact same way as a standard visitor logger

CODE

list recent;
integer max = 50;

default
{
state_entry()
{
llVolumeDetect(TRUE);
recent = [];
}

collision_start(integer total_number)
{
key id = llDetectedKey(0);
if(llListFindList(recent , [ id ] ) < 0)
{
if (llGetInventoryNumber(INVENTORY_NOTECARD) > 0)
{
llGiveInventory(id, llGetInventoryName(INVENTORY_NOTECARD, 0));
}

if (llGetInventoryNumber(INVENTORY_SOUND) > 0)
{
llTriggerSound(llGetInventoryName(INVENTORY_SOUND, 0), 1.0);
}

// Add the visitor
recent = (recent = []) + recent + [ id ];
// Delete the oldest if we exceeed or max count
if(llGetListLength(recent) > max) recent = llDeleteSubList(recent, 0, 0);
}
}
}
_____________________
I'm back......
Benz Bingyi
Registered User
Join date: 21 May 2007
Posts: 48
05-24-2007 14:41
i figured it out.
Everbody who lands on my tp our land will be stored in a list.
people in the list wont get a notecard untill i reset the list.
I also put in a greeter to make it complete.

string welcome;

// Global variables
list visitor_list;
float range = 15.0; // in meters
float rate = 1.0; // in seconds


// Functions
integer isNameOnList( string name )
{
integer len = llGetListLength( visitor_list );
integer i;
for( i = 0; i < len; i++ )
{
if( llList2String(visitor_list, i) == name )
{
return TRUE;
}
}
return FALSE;
}

init()
{
welcome = llGetObjectDesc();
llOwnerSay( "Visitor List Maker started...";);
llOwnerSay( "The owner can say 'help' for instructions.";);
llSensorRepeat( "", "", AGENT, range, TWO_PI, rate );
llListen(0, "", llGetOwner(), "";);
}
// States
default
{
state_entry()
{
init();
}
on_rez( integer param )
{
init();
}
touch_start( integer num )
{
welcome = llGetObjectDesc();
}

sensor( integer number_detected )
{
integer i;
for( i = 0; i < number_detected; i++ )
{
if( llDetectedKey( i ) != llGetOwner() )
{
string detected_name = llDetectedName( i );
if( isNameOnList( detected_name ) == FALSE )
{
llInstantMessage( llDetectedKey( i ), welcome + detected_name);
visitor_list += detected_name;
llOwnerSay ( detected_name + " has been added to your visitors list at " + llGetRegionName() );
llGiveInventory(llDetectedKey(0), "My Notecard.";);
}
}
}
}

listen( integer channel, string name, key id, string message )
{
if( id != llGetOwner() )
{
return;
}

if( message == "help" )
{
llOwnerSay( "This object records the names of everyone who" );
llOwnerSay( "comes within "+ (string)range + " meters." );
llOwnerSay( "Commands the owner can say:" );
llOwnerSay( "'help' - Shows these instructions." );
llOwnerSay( "'say list' - Says the names of all visitors on the list.";);
llOwnerSay( "'reset list' - Removes all the names from the list." );
llOwnerSay ( "TO change the greeting - change the object description and touch the object" );
}
else
if( message == "say list" )
{
llOwnerSay( "Visitor List:" );
integer len = llGetListLength( visitor_list );
integer i;
for( i = 0; i < len; i++ )
{
llOwnerSay( llList2String(visitor_list, i) );
}
llOwnerSay( "Total = " + (string)len );
}
else
if( message == "reset list" )
{
visitor_list = llDeleteSubList(visitor_list, 0, llGetListLength(visitor_list));
llOwnerSay( "Done resetting.";);
}
}
}





It works great.
thanks for everbodies help
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
Lol
05-25-2007 00:20
You did huh? Thats one of my old visitor list scripts.
You should get rid of the isNameOnList function it was written before I knew about llListFindList
_____________________
I'm back......
Sterling Whitcroft
Registered User
Join date: 2 Jul 2006
Posts: 678
05-25-2007 06:30
Cool! The tradition of 'Reusable Code' continues!

I learn a lot by reading your code, Newgate. And sometimes, I even repurpose a snippet or two!

Thank you!;)
Tini Jewell
Registered User
Join date: 19 Feb 2007
Posts: 95
09-08-2007 10:53
Finally, think I found what I'm looking for. But, being totally inexperienced :confused: at scripting, I would appreciate it if someone could tell me which lines I need to change to add my own notecard and maybe a landmark at the same time. Also, do I need to create a note called "visitor list" or does the script do that automatically?

That info about replacing isNameOnList with something ||Listfindlist is totally beyond me too! Where would that go & does anything else need to be done/changed with that?

As I said, I have absolutely no scripting experience and appreciate any help at all with this. Thanks!
_____________________
Opening Soon!
SPELL-IT-OUT Proofreading & Copy Editing Service
Tini Jewell
Registered User
Join date: 19 Feb 2007
Posts: 95
09-08-2007 10:54
Finally, think I found what I'm looking for. But, being totally inexperienced :confused: at scripting, I would appreciate it if someone could tell me which lines I need to change to add my own notecard and maybe a landmark at the same time. Also, do I need to create a note called "visitor list" or does the script do that automatically?

That info about replacing isNameOnList with something ||Listfindlist is totally beyond me too! Where would that go & does anything else need to be done/changed with that?

As I said, I have absolutely no scripting experience and appreciate any help at all with this. Thanks!