Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Avatar in sim or not?

Bisham Ren
Registered User
Join date: 1 Jul 2006
Posts: 19
05-23-2008 06:29
Hello,

if I know an agent's key, is there any function that can tell me whether he is in the sim or not?

I considered llKey2Name which would otherwise return an empty string, but apparently it will return a name even if the agent can see the sim from an adjacent sim, so that is no good.
Shyan Graves
Registered User
Join date: 10 Feb 2007
Posts: 52
llGetAgentSize()
05-23-2008 07:46
Hi,


how about using vector llGetAgentSize( key id );
this function returns a ZERO_VECTOR if agent is not in the same region (SIM).
At least that is what the WIKI states! And I know some scipts use it to check if the owner is in the same region. See also example in the WIKI



Regards,
Shyan
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
05-23-2008 09:36
We now have llGetObjectDetails() too. If an avatar is out of range, it returns an empty list. The range can extend beyond the current sim, but then the position should indicate a value outside the bounds of the sim, right? I propose:

CODE

integer isAvatarInSim(key avatar)
{
list details = llGetObjectDetails(avatar [ OBJECT_POS ]);
if (llGetListLength(details) < 1
{
return FALSE;
}

vector pos = llList2Vector(details, 0);
return (pos.x >= 0.0 && pos.x <= 256.0 &&
pos.y >= 0.0 && pos.y <= 256.0 &&
pos.z >= 0.0 && pos.z <= 256.0);
}
Diag Anzac
Registered User
Join date: 27 Oct 2006
Posts: 45
05-23-2008 18:38
CODE
key agent_key = "key-of-avatar-you-are-interested-in";

default
{
touch_start(integer total_number)
{
if (llGetAgentInfo(agent_key))
{
llSay(0,(string)agent_key + " is in the sim.");
}
else
{
llSay(0,(string)agent_key + " is absent.");
}
}
}
Bisham Ren
Registered User
Join date: 1 Jul 2006
Posts: 19
05-26-2008 07:28
Thanks all, that helped a lot!