Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

permission

Gus Udal
Registered User
Join date: 4 Dec 2005
Posts: 18
05-12-2006 20:59
In this vehicle script, is there a way to give permissions to any agent to drive, without them being the owner?

changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
if (agent != llGetOwner())
{
llSay(0, "You aren't the owner";);
llUnSit(agent);
llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
}
else
{
// You sit and are owner so get controls
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llRequestPermissions(agent,PERMISSION_TAKE_CONTROLS);
}
}
else
{
// You stand so boat stops
llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", NULL_KEY);
llSetStatus(STATUS_PHYSICS, FALSE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llReleaseControls();
llStopSound();
llSetTimerEvent(0.0);
}
}

}

run_time_permissions(integer perm)
{
if (perm)
{
// Take these controls and lets go
llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
05-12-2006 23:25
Simply change this part:
CODE
if (agent)
{
if (agent != llGetOwner())
{
llSay(0, "You aren't the owner");
llUnSit(agent);
llPushObject(agent, <0,0,100>, ZERO_VECTOR, FALSE);
}
else
{
// You sit and are owner so get controls
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llRequestPermissions(agent,PERMISSION_TAKE_CONTROL S);
}
}


to this:

CODE
if (agent)
{
// You sit and are owner so get controls
llSetStatus(STATUS_PHYSICS, TRUE);
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);
llRequestPermissions(agent,PERMISSION_TAKE_CONTROL S);
}
_____________________
- Making everyone's day just a little more surreal -

Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-12-2006 23:34
comment out the line if(agent!=llGetOwner()) and the following span (llUnsit() and the push), that will then run straight through into setting up perms. It will, however, allow anyone to drive it.

If you want it more restrictive than that it gets a bit more complicated. You need the if(agent != llGetOwner()) line back in, and some method to prompt the owner to give permission when appropriate. There are lots of ways around that - one of the commonest is to have multiple seats and allow anyone to drive as long as the owner is actually on the vehicle - but that's no good for 1 seaters. The other is to set a "guest driver" and set their name, or key, in a particular place (description field of the seat prim for example) and check if that matches with the name/key of the avatar as appropriate.
Gus Udal
Registered User
Join date: 4 Dec 2005
Posts: 18
05-13-2006 03:26
Thank you. :)