Leo1452 Posted September 30, 2020 Posted September 30, 2020 I'm looking to unseat everyone who sits on a particular object except for the first person to sit on it.
Phate Shepherd Posted September 30, 2020 Posted September 30, 2020 The wiki example for llAvatarOnLinkSitTarget shows how to unseat anyone but the first to sit. http://wiki.secondlife.com/wiki/LlAvatarOnLinkSitTarget 1
KT Kingsley Posted September 30, 2020 Posted September 30, 2020 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.
Rolig Loon Posted September 30, 2020 Posted September 30, 2020 (edited) 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 September 30, 2020 by Rolig Loon 1
KT Kingsley Posted September 30, 2020 Posted September 30, 2020 Hah! Never noticed OBJECT_SIT_COUNT before. But llUnSit needs the key of the avatar being unseated, not the link number. 1
Mollymews Posted September 30, 2020 Posted September 30, 2020 a way with Rolig's suggested method if (change & CHANGED_LINK) { if (llList2Integer(llGetObjectDetails(llGetKey(),[OBJECT_SIT_COUNT]), 0) > 1) { // unsit the last person to sit llUnSit(llGetLinkKey(llGetNumberOfPrims())); } } 1
Rolig Loon Posted September 30, 2020 Posted September 30, 2020 20 minutes ago, KT Kingsley said: But llUnSit needs the key of the avatar being unseated, not the link number. Yeah, oops. And thank you, Molly. My brain wasn't quite where I thought it was. 1
Chic Aeon Posted September 30, 2020 Posted September 30, 2020 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.
Mollymews Posted September 30, 2020 Posted September 30, 2020 8 minutes ago, Rolig Loon said: Yeah, oops. And thank you, Molly. My brain wasn't quite where I thought it was. i think there might be something in the ether as my own brains fell out yesterday on another post 😺 1
Qie Niangao Posted September 30, 2020 Posted September 30, 2020 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.) 5
Recommended Posts
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