Jump to content

Letting others temporarily use vehicles


Miguelito Shilova
 Share

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

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

Recommended Posts

If you really want each user to get a personal copy of the vehicle, then it goes into their inventory by definition.  If that's the route you choose, then you have to write the script for the vehicle in such a way that it is destroyed or disabled after some period of time.  That's done with certain food items, for example.

If you just want people to be able to ride in the vehicle, then you don't need to do anything to give them permission.  Just leave copies lying around and be sure that you don't include anything in the script that specifically restricts users [like if(llAvatarOnSitTarget() != llGetOwner()) , for example].  You'll probably just want to script some limitation to prevent them from driving it out of your sim, or after some time limit has expired, or whatever.

If you don't want copies just left around all the time, create them on demand with a rezzer.  Put a timed llDie command in the vehicle's script so that a copy vanishes after a preset amount of time.

Link to comment
Share on other sites

As the others mentioned earlier, you can't restrict it so it can't be taken. I would also suggest a CHANGED_LINK event. something like:

 

changed (integer change){   if (change & CHANGED_LINK)   {     agent=llAvatarOnSitTarget();     if (agent==NULL_KEY)     {       llDie();       llSetTimerEvent(1);     }   }}timer(){  llDie();}

I might have messed up somewhere since I just made this up without testing.) Which simply deletes the vehicle when the driver stands up. Oh and of course make sure to set the permissions for your vehicle to "no copy".

Link to comment
Share on other sites

No need for the llDie in the changed event.  If you put it there, it wipes out the timer anyway.  Try ....

changed (integer change){   if (change & CHANGED_LINK)   {     if (llAvatarOnSitTarget()== NULL_KEY)     {       llSetTimerEvent(20.0);   //Give the user some time to change her mind and sit down again     }   }}timer(){    if(llAvatarOnSitTarget())    {        llSetTimerEvent(0.0);    }    else    {        llDie();    }}

 

Link to comment
Share on other sites

You should probably be aware that this method will fail if your user gets off the vehicle in a parcel where scripts are not allowed.  Vehicle scripts will continue to function if you ride into a no-scripts parcel, but once you stand up the rules change and the script is disabled.  That means its timer will never trigger and the llDie will not execute.  You'll have to clean up after your clients manually.  Of course, they won't be able to move the dead vehicle either, so your primary goal will still have been met. 

Link to comment
Share on other sites

As soon as you stand up, permissions are revoked.  I have a rezzer that generates tour vehicles on demand for anyone visiting our sims, each of which uses exactly this method for cleanup.  It works beautifully except in the four parcels whose managers have marked them no-script areas.  If a visitor abandons a tour vehicle anywhere else, it poofs in 20 seconds.  If it's abandoned in a no-script parcel, the script stops dead and I have to go clean up myself.  It's annoying, but not enough to make me give up the tour vehicle fleet. 

Link to comment
Share on other sites

Thanks.  I've just tested it with this, and you're right.   Looks like the wiki is misleading about that -- I certainly read it as meaning the script keeps controls.

 

default{    state_entry()    {       llSitTarget(<0.0,0.0,0.5>,ZERO_ROTATION);    }        changed(integer change){        if(change & CHANGED_LINK){            key k = llAvatarOnSitTarget();            if(k){                llRequestPermissions(k,PERMISSION_TAKE_CONTROLS);            }        }    }        run_time_permissions(integer perm){        if(perm & PERMISSION_TAKE_CONTROLS){            llTakeControls(CONTROL_FWD,FALSE,TRUE);        }    }    touch_start(integer total_number)    {        key k = llDetectedKey(0);        if(llGetPermissions()& PERMISSION_TAKE_CONTROLS){            llRegionSayTo(k,0,"got controls");        }        else{            llRegionSayTo(k,0,"not got controls");        }    }}

 

Link to comment
Share on other sites

  • 7 months later...

hello

I am new with script would please help me to arrange following script so that anyone can drive my vehicle

 

default{    state_entry()    {        stuntparams();        Vname=llGetObjectName();        llSetTimerEvent(0.0);        llStopSound();        llSetStatus(STATUS_PHYSICS, FALSE);        llMessageLinked(LINK_ALL_CHILDREN, 0, "stop", NULL_KEY);        llWhisper(0,Vname + " is ready for use");        llWhisper(0,"change sittarget to stand on for diffrent hight avs");    }    on_rez(integer start_param)    {        llResetScript();    }     touch(integer total_number)    {        key owner=llGetOwner();        if (llDetectedKey(0)==owner)        {            help();        }        else        {            llWhisper(0,llDetectedName(0) + ", Please step away from the " + Vname);        }     }    changed(integer change)    {        avatar = llAvatarOnSitTarget();        string name=llKey2Name(avatar);        if(change & CHANGED_LINK)        {            if(avatar == NULL_KEY)            {                //  You have gotten off                llSetTimerEvent(0.0);                llStopSound();                llMessageLinked(LINK_ALL_CHILDREN, 0, "stop",  NULL_KEY);                llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);                llReleaseControls();                llStopAnimation("surf");                sit = FALSE;                llPushObject(llGetOwner(), <0, 2, 7>, <0,0,0>, TRUE);                llSetStatus(STATUS_PHYSICS, FALSE);                llResetScript();            }            else if(avatar == llGetOwner())            {                // You have gotten on                llSetStatus(STATUS_PHYSICS, TRUE);                llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);                sit = TRUE;                llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);            }            else            {                llWhisper(0,name + ", Please step away from the " + Vname);                llUnSit(avatar);            }        }    }    run_time_permissions(integer perms)    {        if(perms & (PERMISSION_TAKE_CONTROLS))        {            llStopAnimation("sit");            llStartAnimation("surf");            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT | CONTROL_UP | CONTROL_DOWN, TRUE, FALSE);            llMessageLinked(LINK_ALL_CHILDREN, 0, "rotor",  NULL_KEY);            llLoopSound("jet0",0.7);            llSetTimerEvent(0.2);        }        else        {            llUnSit(avatar);        }    }

Regards

 

 

Link to comment
Share on other sites

It's all quite logical.  Just change

            else if(avatar == llGetOwner())            {                // You have gotten on                llSetStatus(STATUS_PHYSICS, TRUE);                llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);                sit = TRUE;                llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);            }            else            {                llWhisper(0,name + ", Please step away from the " + Vname);                llUnSit(avatar);            }

to

            else             {                // You have gotten on                llSetStatus(STATUS_PHYSICS, TRUE);                llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE);                sit = TRUE;                llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);            }

 Not necessary for functioning, but you might also want to change

    touch(integer total_number)    {        key owner=llGetOwner();        if (llDetectedKey(0)==owner)        {            help();        }        else        {            llWhisper(0,llDetectedName(0) + ", Please step away from the " + Vname);        }     }

to

    touch(integer total_number)    {            help();    }

 

Link to comment
Share on other sites

Thank you,

 I try it it is working with other than the owner.

now the problem with the other seat if someone sit on the other seat gives error

Script trying to stop animations but PERMISSION_TRIGGER_ANIMATION permission not set

 this is the script on the second  seat can we change it so it will not effect the main script of vehicle

 

string animation;string SIT_TEXT=""; default  {    state_entry()      {    if        (llStringLength(SIT_TEXT)>0)llSetSitText(SIT_TEXT);     }     changed(integer change)              {        if (change & CHANGED_LINK)                {        if (llAvatarOnSitTarget() != NULL_KEY)                    {        llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);                    }        else                        {        integer perm=llGetPermissions();        if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(animation)>0)        llStopAnimation(animation);        animation="";                        }                }            }     run_time_permissions(integer perm)    {        if (perm & PERMISSION_TRIGGER_ANIMATION)        {                llStopAnimation("sit");                animation=llGetInventoryName(INVENTORY_ANIMATION,0);                llStartAnimation(animation);        }    }}

 

Link to comment
Share on other sites

If you put both scripts in the same linkset, they will interfere with each other, because the are both going to react when anyone sits in either seat.  I suggest combining the two scripts into a single one and using llLinkSitTarget and llAvatarOnLinkSitTarget to allow for separate behavior on the two seats.

Link to comment
Share on other sites

Hi again

If the name of the second seat (Rider)  how i use  llGetLinkName() so it will not react with the main script?

I try with this but didnt work whats rong?

 

 changed(integer change)    {        avatar = llAvatarOnSitTarget();        string name=llKey2Name(avatar);        if(change & CHANGED_LINK)        {            if(avatar == NULL_KEY)            {                //  You have gotten off                llSetTimerEvent(0.0);                llStopSound();                llMessageLinked(LINK_ALL_CHILDREN, 0, "stop",  NULL_KEY);                llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);                llReleaseControls();                llStopAnimation("surf");                sit = FALSE;                llPushObject(llGetOwner(), <0, 2, 7>, <0,0,0>, TRUE);                llSetStatus(STATUS_PHYSICS, FALSE);                llResetScript();            }                    //   String Rider=llGetLinkName();                                  else if (llGetLinkName() == Rider)                                  {         
} else { // You have gotten on llSetStatus(STATUS_PHYSICS, TRUE); llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, TRUE); sit = TRUE; llRequestPermissions(avatar,PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION);

 

 

Link to comment
Share on other sites

I'm not sure what you are trying to do there.  Did you study the wiki pages for llLinkSitTarget and llAvatarOnLinkSitTarget?  So long as you have two link sit targets defined properly, you can deal with each of the people sitting on a seat separately in the the same script.

If an object has multiple seats (each seat has a script that sets a sit target with llSitTarget, or the linkset has a script that assigns several llLinkSitTargets), the following method determines which sit target an avatar ends up at:

  • If the prim that is clicked on has a sit target and that sit target is not full, that sit target is used.
  • If the prim that is clicked on has no sit target, and one or more other linked prims have sit targets that are not full, the sit target of the prim with the lowest link number will be used.

So,as long as the driver's seat has a lower link number than the passenger's seat, The driver's seat will be the default place where someone who clicks randomly on your vehicle ends up.  If there's someone in the driver's seat, or if someone clicks directly on the passenger's set, the person will end up in the passenger's seat.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4182 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...