Jump to content

How to obtain avatar id sitting on a prim?


Echelon Alcott
 Share

You are about to reply to a thread that has been inactive for 822 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Let's say that I have prim A with a script in it, and prim B with an avatar sitting on it. 

Let's say that in prim A, the script knows the UUID of prim B. How can the script in prim A get the id of avatar sitting on prim B?

In the script in prim A, I was able to use llGetObjectDetails and get the sit count of prim B using OBJECT_SIT_COUNT, but I can't figure out how to get the id of the avatar sitting on prim B.

Thanks for your assistance.

Link to comment
Share on other sites

I'm assuming that Prim B is not yours, so the easy answer -- put a script in prim B that just gets llAvatarOnSitTarget or llGetLinkKey(llGetNumberOfPrims()) -- isn't possible. Therefore, there's no direct, simple way.  I suggest either using a sensor or llGetAgentList to get the UUIDs of avatars in range and then check to see which avatar is within, say, 0.5m of prim B.  Or you could fire a llCastRay at the avatar, I suppose. I would go for the sensor.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

You could try doing it backwards, for every agent that passes some initial check (raycast, agentlist, sensor), get the key of the object the avatar is sitting on with llGetObjectDetails(ID,[OBJECT_ROOT]); and whichever ones happen to return the key of the object you're interested in, will be sitting on it. (multiple people can be sitting on a thing. if it has more than one prim in its linkset)

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

I assume your prims are linked and I believe I had to so something like this for a someone to unsit someone from a stage while a performer was on it or only allow the specified performers to use the stage.

Based on looking at my code when an avatar sits on an object the avatar is treated like another linked prim. So here is a snip of the code I used.

unsitExtraAgent()
{
	list linkedStuff = [];  //create empty list
	integer numberOfItems = llGetNumberOfPrims();  //get number of prims for this object
	integer end = numberOfItems + 1;
	integer i = 0; //loop counter
    //loop through prims in object to get name of each prim and add to list linkedStuff
	do
	{
		linkedStuff = linkedStuff + llGetLinkName(i);
		i++;
	}while (i != end);

    //get key of last "prim" of object, should be our avatar
	key temp = llGetLinkKey(llGetListLength(linkedStuff) - 1);  

	if (currentAvatar != temp)  //cuyrentAvatar was a global variable for whom should be on the "stage"
	{
		llUnSit(temp);
		llInstantMessage(temp, "Only one person can use me at a time");
	}
}

 

  • Thanks 1
Link to comment
Share on other sites

4 hours ago, Wicc Cunningham said:

I assume your prims are linked and I believe I had to so something like this for a someone to unsit someone from a stage while a performer was on it or only allow the specified performers to use the stage.

Based on looking at my code when an avatar sits on an object the avatar is treated like another linked prim. So here is a snip of the code I used.

unsitExtraAgent()
{
	list linkedStuff = [];  //create empty list
	integer numberOfItems = llGetNumberOfPrims();  //get number of prims for this object
	integer end = numberOfItems + 1;
	integer i = 0; //loop counter
    //loop through prims in object to get name of each prim and add to list linkedStuff
	do
	{
		linkedStuff = linkedStuff + llGetLinkName(i);
		i++;
	}while (i != end);

    //get key of last "prim" of object, should be our avatar
	key temp = llGetLinkKey(llGetListLength(linkedStuff) - 1);  

	if (currentAvatar != temp)  //cuyrentAvatar was a global variable for whom should be on the "stage"
	{
		llUnSit(temp);
		llInstantMessage(temp, "Only one person can use me at a time");
	}
}

 

Thanks for your reply, Wicc. In the problem I was trying to solve, the prims are not linked, but nonetheless, thanks for sharing your thoughts!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 822 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...