Jump to content

Only allow one avatar to sit on object


Leo1452
 Share

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

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

Recommended Posts

If the object has a sit target, the first avatar to sit gets to use it and subsequent avatars don't. So the first avatar to sit is the one who's key is returned by llAvatarOnSitTarget.

So, whenever the changed event is triggered with the CHANGED_LINK bit set in the changes parameter you can loop through the links and use llGetAgentSize to check if it's an avatar, and if it is then check if it's the avatar on the sit target. If it isn't you can use llUnSit to unsit them.

Seated avatars are given link numbers that count up from the highest link number (unlike additional prims that are linked to an existing object which are inserted as link number 2, with all the others being bumped up). Thus when you scan the link set you can start with the highest link and work back to the avatar on the sit target. llGetNumberOfPrims will tell you where to start the loop if you count backwards (counting forwards can run into the problem of the number of links reducing as unwanted avatars are unseated).

I'm tired and I'm not in-world to check what I've just written, so I may be going wrong somewhere, but I think I'm making sense here.

Link to comment
Share on other sites

Maybe the easiest way is to use llGetObjectDetails.

integer iSitCount = llList2Integer(llGetObjectDetails(llGetKey(),[OBJECT_SIT_COUNT]), 0);

then

if (iSitCount > 1)
{
     llUnSit(llGetNumberOfPrims());
}

That would work, since the last person to sit down is always the most recent link to be added to the linkset.  If necessary, you can repeat the test to see if there's yet another person on the object.

You could also put this entire test in a changed event, to be triggered if (change & CHANGED_LINK)

Edited by Rolig Loon
  • Like 1
Link to comment
Share on other sites

OK. This is VERY Simplistic and I am not a script person by any means but if you use AVsitter (now free) and only have one person sit, no one else can sit.   When they try they get bounced off. Not sure if that is what you are after. A little unclear for me, but throwing that into the mix. 

 

This for @Leo1452 obviously :D.  

 

 

Link to comment
Share on other sites

To merely prevent multiple sitters (as opposed to unseating them), I've used something like this:

default
{
    state_entry()
    {   // just make it easy to test:
        llSetLinkPrimitiveParamsFast(LINK_SET, 
            [ PRIM_SIT_TARGET, TRUE, <0, 0, 0.5>, ZERO_ROTATION
            , PRIM_SCRIPTED_SIT_ONLY, FALSE
            ]);
    }
    changed(integer change)
    {
        if (CHANGED_LINK & change)
            if (ZERO_VECTOR != llGetAgentSize(llGetLinkKey(llGetNumberOfPrims())))
                llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_SCRIPTED_SIT_ONLY, TRUE]);
            else
                llSetLinkPrimitiveParamsFast(LINK_SET, [PRIM_SCRIPTED_SIT_ONLY, FALSE]);
    }
}

(That state_entry is totally disposable; it just sets up a linkset to demo the function.)

  • Like 5
Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...