Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Group only sit-on

Jonesey Spitteler
Builder / Shop Owner
Join date: 19 May 2007
Posts: 60
11-05-2007 13:34
Hi there...

I have this chair, that I got some place... It's really cool and has some nice sit-anims. I need to make it group only though. The thing is... the scripts in the chair are not modifiable... but the chair itself is... So here's my question: Can I put a script in the chair that will make it possible only for group members to sit in it? And what should that script look like?

/Jonesey
Smithy Zeno
ownes 9 pet cacti
Join date: 3 Aug 2006
Posts: 52
11-05-2007 14:58
Hi Jonesey,

I just wrote this script. I'm not inworld atm and wrote it here, but it should work. I'll test it out when I get a chance :D

From: Darkboy Spackler:


string person;

default
{
on_rez(integer start)
{
llResetScript();
}
state_entry()
{
llSay(0, "on";);
llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);//You may think this is unessesary, but you need this to trigger llAvatarOnSitTarget.
}

changed(integer c)
{
person = llAvatarOnSitTarget();
if(llSameGroup(person))
{
llSay(0, "You are in the right group!";);
}
else
{
}
}
}


-Smithy
Jonesey Spitteler
Builder / Shop Owner
Join date: 19 May 2007
Posts: 60
11-05-2007 15:08
Well... It does check for the group... but if I dont have the group tag on, it shoulf unsit me... and it doesnt... any solutions?

/Jonesey
Smithy Zeno
ownes 9 pet cacti
Join date: 3 Aug 2006
Posts: 52
11-05-2007 15:18
Here you go:


From: Darkboy Spackler:

string person;

default
{
on_rez(integer start)
{
llResetScript();
}
state_entry()
{
llSay(0, "on";);
llSitTarget(<0.0, 0.0, 0.1>, ZERO_ROTATION);//You may think this is unessesary, but you need this to trigger llAvatarOnSitTarget.
}

changed(integer c)
{
person = llAvatarOnSitTarget();
if(llSameGroup(person))
{
llSay(0, "You are in the right group!";);
}
else
{
llUnSit(person);
}
}
}
_____________________
-Smithy
Jonesey Spitteler
Builder / Shop Owner
Join date: 19 May 2007
Posts: 60
11-05-2007 21:47
Smithy, thanks, of course I didnt think of that myself...
1 more problem: it does unsits me when i dont have the group active... but only once in a while (like every second/third time)... not every time...
_____________________
Best Regards,
Jonesey Spitteler
- The Partyshack -
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
11-06-2007 00:42
Add a llSleep(0.5) before the llUnsit() and it should unsit the avatars that do *not* have the proper group tag active more reliably.
Cordax Martinek
Registered User
Join date: 7 May 2007
Posts: 14
I am new to this so pls forgive
11-06-2007 08:07
I was trying the script above and notice when I added the llSleep(0.5)
anyone that is having problems with it might want to add a ; after the sleep
like this
llSleep(0.5);


hope that helps someone... trying to be helpful...if that is wrong someone pls correct me ...I will fix my post...
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
Is it wise to set a sit target?
11-06-2007 08:35
Setting a sit target may interfere with what the existing scripts are doing as they must also be setting a sit target... otherwise they wouldn't function correctly. The new script should still pick up the change event and unsit correctly.

Also, llAvatarOnSitTarget and llUnSit, work with keys therefore 'person' should be defined as a key - or are keys and strings really interchangeable?

And finally - sorry about this! - the change event would normally check for if(change & CHANGED_LINK) with respect to seating arrangements, so I submit...


CODE

key person;

default
{
on_rez(integer start)
{
llResetScript();
}

state_entry()
{
llSay(0, "on");
}

changed(integer c)
{
if(change & CHANGED_LINK)
{
person = llAvatarOnSitTarget();
if (person != NULL_KEY)
if(llSameGroup(person)) llSay(0, "You are in the right group!");
else
{
llSleep(0.5); // not entirely convinced this is required
llUnSit(person);
}
}
}
}
}



EDIT: oops, thought of another thing! :p

If the avatar unseats themselves we also need to check person hasn't become NULL_KEY or a nasty warning triangle will appear.
Smithy Zeno
ownes 9 pet cacti
Join date: 3 Aug 2006
Posts: 52
11-06-2007 08:47
From: Pale Spectre
Setting a sit target may interfere with what the existing scripts are doing as they must also be setting a sit target... otherwise they wouldn't function correctly. The new script should still pick up the change event and unsit correctly.



If I'm not mistaken, you need llSitTarget to detect the key of the avatar sitting. Sorry, if I'm mistaken, but there is a quote below from the LSL Wiki.

From: LSL Wiki:


llAvatarOnSitTarget will only work if llSitTarget has been set.

_____________________
-Smithy
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
11-06-2007 08:55
You are correct... but the existing script(s) must already be setting a sit target and not necessarily with: (<0.0, 0.0, 0.1>, ZERO_ROTATION)

llSitTarget is a property of the prim and not the script.
Jonesey Spitteler
Builder / Shop Owner
Join date: 19 May 2007
Posts: 60
Thanks
11-06-2007 11:57
This really helped me out guys. Thanks a lot :D

/Jonesey
Jonesey Spitteler
Builder / Shop Owner
Join date: 19 May 2007
Posts: 60
11-06-2007 14:05
Hmmmm.... I was a bit too fast there... it still doesnt work... now it doesnt even verify that im in the group....

/Jonesey
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
11-06-2007 15:12
From: Jonesey Spitteler
Hmmmm.... I was a bit too fast there... it still doesnt work... now it doesnt even verify that im in the group....
...or do you mean it doesn't compile? :D

CODE

key person;

default
{
on_rez(integer start)
{
llResetScript();
}

state_entry()
{
llSay(0, "on");
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
person = llAvatarOnSitTarget();
if (person != NULL_KEY)
{
if(llSameGroup(person)) llSay(0, "You are in the right group!");
else
{
//llSleep(0.5); // not entirely convinced this is required
llUnSit(person);
}
}
}
}
}



This one is tested. It also seems to work fine without the llSleep (quicker unsit too).

You do know that a lot of code in here gets written on the back of a fag packet? :eek: