Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How can I tell the number of people on my land in a script?

Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
03-17-2005 10:52
As the title said, How can I tell the number of people on my land in a script?

I want to have specific things happen if a certain number of people are on my land at one time. A simple idea, but I have yet to find a way to impliment it...
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
03-17-2005 10:58
Have you tried using one more more sensors?

http://secondlife.com/badgeo/wakka.php?wakka=llSensor

You can use the sensor to detect what agents are nearby then have your script find their sim position and check that against the boundries of your land.
Tiger Crossing
The Prim Maker
Join date: 18 Aug 2003
Posts: 1,560
03-17-2005 12:34
CODE
// snippet: (not complete code)

integer gLastCount = 0;

sensor( integer num )
{
integer count = 0;
integer a;
for ( a=0; a<num; ++a ) // check each person the sensor finds
{
// if the owner of the land they are over is the same as the
// owner of the land this script is on, add 1 to the count
if ( llGetLandOwnerAt( llDetectedPos( a ) ) == llGetLandOwnerAt( llGetPos() ) )
++count;
}

if ( count != gLastCount ) // if the count has changed
{
llSay( 0, "There are now "+(string)count+" people on this plot." );
llSetText( "Avatars: "+(string)count, <1,1,1>, 1 );
gLastCount = count;
}
}
_____________________
~ Tiger Crossing
~ (Nonsanity)
Foolish Frost
Grand Technomancer
Join date: 7 Mar 2005
Posts: 1,433
03-18-2005 03:43
Thanks! Good idea on the design!