Notecards will only be given once because a list is being created with avatars who allready recieved the notecard.
This can be resetted when you reset the list whit the command: reset list
CODE
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), "Benz Shop low priced lots of flexi items.");
}
}
}
}
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.");
}
}
}