Jump to content

Help making this script owner only.


TrinityReclusive
 Share

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

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

Recommended Posts

This script works great for what i need just cant seem to make it owner only to use the boat.

Can some one fix it plaese.. its giving me a headache.. smile

-------------------------------------------------------------------------------------------------------------------


integer effects =0;
float forward_power = 25; //Power used to go forward (1 to 30)
float reverse_power = -5; //Power ued to go reverse (-1 to -30)
float turning_ratio = 1.6; //How sharply the vehicle turns. Less is more sharply. (.1 to 10)
string sit_message = "DRIVE"; //Sit message
string not_owner_message = "You are not the owner of this vehicle ..."; //Not owner message
string drive_anim = "Sit";

float curRot;

integer shouldDie = 0;

//Anything past this point should only be modfied if you know what you are doing

stoppsystem()
{
        llLinkParticleSystem(2, []);
}
psystem()
{
     llLinkParticleSystem(2,
        [
            PSYS_SRC_PATTERN,PSYS_SRC_PATTERN_EXPLODE,
            PSYS_SRC_BURST_RADIUS,.3,
            PSYS_SRC_ANGLE_BEGIN,PI/2,
            PSYS_SRC_ANGLE_END,PI/2 + 0.1,
            PSYS_SRC_TARGET_KEY,llGetKey(),
            PSYS_PART_START_COLOR,<1.000000,1.000000,1.000000>,
            PSYS_PART_END_COLOR,<1.000000,1.000000,1.000000>,
            PSYS_PART_START_ALPHA,.7,
            PSYS_PART_END_ALPHA,0.,
            PSYS_PART_START_GLOW,0,
            PSYS_PART_END_GLOW,0,
            PSYS_PART_BLEND_FUNC_SOURCE,PSYS_PART_BF_SOURCE_ALPHA,
            PSYS_PART_BLEND_FUNC_DEST,PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA,
            PSYS_PART_START_SCALE,<1.30000,1.00000,0.000000>,
            PSYS_PART_END_SCALE,<2,2, 0.000000>,
            PSYS_SRC_TEXTURE,"3a7ea058-e486-4d21-b2e6-8b47462bb45b",
            PSYS_SRC_MAX_AGE,0,
            PSYS_PART_MAX_AGE,6,
            PSYS_SRC_BURST_RATE,0.01,
            PSYS_SRC_BURST_PART_COUNT,4,
            PSYS_SRC_ACCEL,<0.000000,0.000000,-1.00000>,
            PSYS_SRC_OMEGA,<0.000000,0.000000,0.000000>,
            PSYS_SRC_BURST_SPEED_MIN,0.6,
            PSYS_SRC_BURST_SPEED_MAX,0.6,
            PSYS_PART_FLAGS,
                0
                | PSYS_PART_INTERP_COLOR_MASK
                | PSYS_PART_INTERP_SCALE_MASK
                | PSYS_PART_BOUNCE_MASK
                | PSYS_PART_EMISSIVE_MASK
        ]);
}


setVehicle() {
        
        llSetCameraEyeOffset(<-14, 0.0, 3.0>);
        
        llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE]);
        llSetVehicleFlags(0);
        llSetVehicleType(VEHICLE_TYPE_BOAT);
        llSetVehicleFlags(VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_HOVER_WATER_ONLY);
        llSetVehicleVectorParam( VEHICLE_LINEAR_FRICTION_TIMESCALE, <.8, .8, 1> );
        llSetVehicleFloatParam( VEHICLE_ANGULAR_FRICTION_TIMESCALE, 3 );

        
        
        llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <0, 0, 0>);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 1);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.05);
        
        llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_TIMESCALE, 1 );
        llSetVehicleFloatParam( VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 5 );
        llSetVehicleFloatParam( VEHICLE_HOVER_HEIGHT, 0.15);
        llSetVehicleFloatParam( VEHICLE_HOVER_EFFICIENCY,.5 );
        llSetVehicleFloatParam( VEHICLE_HOVER_TIMESCALE, 2.0 );
        llSetVehicleFloatParam( VEHICLE_BUOYANCY, 1 );
        llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.5 );
        llSetVehicleFloatParam( VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 3 );
        llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.5 );
        llSetVehicleFloatParam( VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 10 );
        llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.5 );
        llSetVehicleFloatParam( VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 2 );
        llSetVehicleFloatParam( VEHICLE_BANKING_EFFICIENCY, 1 );
        llSetVehicleFloatParam( VEHICLE_BANKING_MIX, 0.1 );
        llSetVehicleFloatParam( VEHICLE_BANKING_TIMESCALE, .5 );
        llSetVehicleRotationParam( VEHICLE_REFERENCE_FRAME, ZERO_ROTATION );
        
    }


string curanim;

default
{
    
    on_rez(integer n)
    {
        llResetScript();   
    }
    
    state_entry()
    {
        //llSetSitText(sit_message);
        // forward-back,left-right,updown
        llSitTarget(<0.9,0.3,3.0>, llEuler2Rot(<0,0,0>) );
        
         llSetCameraEyeOffset(<-10, 0, 3>);
        llSetCameraAtOffset(<10, 0, 0>);
        
        setVehicle();
        
        shouldDie = 0;
        llSetTimerEvent(60);
    }
    
    changed(integer change)
    {
        
        
        if (change & CHANGED_LINK)
        {
            
            key agent = llAvatarOnLinkSitTarget(1);
            if (agent != NULL_KEY)
            {           
                llSetTimerEvent(0);
                setVehicle();     

                                        
                    stoppsystem();            
                    //llMessageLinked(LINK_ALL_CHILDREN , 0, "start", NULL_KEY);
                    llRequestPermissions(agent,  PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS| PERMISSION_CONTROL_CAMERA);
                    //llSetLinkAlpha(2, 0.0, ALL_SIDES);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    llSleep(.4);
                    shouldDie = 0;


            }
            else
            {
                //llStopSound();
                
                llSetStatus(STATUS_PHYSICS, FALSE);
                llSleep(.2);
                llReleaseControls();
                llTargetOmega(<0,0,0>,PI,0);
                llStopAnimation("swim");
                llStopAnimation("tread");
                llSetTimerEvent(0);
                //llSetLinkAlpha(2,1.0, ALL_SIDES);
                vector r = llRot2Euler(llGetRot());
                r.x =0;
                r.y =0;
                llSetRot(llEuler2Rot(r));
                stoppsystem();
                
                llSetTimerEvent(60);
            }
        }
        
    }
    
    run_time_permissions(integer perm)
    {
        if (perm&PERMISSION_TAKE_CONTROLS)
        {
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT |
                            CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT, TRUE, FALSE);
                            
                            
                                        
            llSetCameraParams([
                       CAMERA_ACTIVE, 1,                     // 0=INACTIVE  1=ACTIVE
                       CAMERA_BEHINDNESS_ANGLE, 15.0,         // (0 to 180) DEGREES
                       CAMERA_BEHINDNESS_LAG, 1.0,           // (0 to 3) SECONDS
                       CAMERA_DISTANCE, 6.0,                 // ( 0.5 to 10) METERS
                       CAMERA_PITCH, 20.0,                    // (-45 to 80) DEGREES
                       CAMERA_POSITION_LOCKED, FALSE,        // (TRUE or FALSE)
                       CAMERA_POSITION_LAG, 0.05,             // (0 to 3) SECONDS
                       CAMERA_POSITION_THRESHOLD, 30.0,       // (0 to 4) METERS
                       CAMERA_FOCUS_LOCKED, FALSE,           // (TRUE or FALSE)
                       CAMERA_FOCUS_LAG, 0.01 ,               // (0 to 3) SECONDS
                       CAMERA_FOCUS_THRESHOLD, 0.01,          // (0 to 4) METERS
                       CAMERA_FOCUS_OFFSET, <0.0,0.0,0.0>   // <-10,-10,-10> to <10,10,10> METERS
                      ]);
        }
        if (perm & PERMISSION_TRIGGER_ANIMATION)
        {
            //llStartAnimation(drive_anim);
        }
    }
    
    control(key id, integer level, integer edge)
    {
        integer reverse=1;
        vector angular_motor;
        
        //get current speed
        vector vel = llGetVel();
        float speed = llVecMag(vel);
        integer moving=0;
        float newRot;
        //car controls
        if(level & CONTROL_FWD)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <forward_power,0,0>);
            reverse=1;
            if (!(edge & CONTROL_FWD))
                moving=1;
            
        }
        if(level & CONTROL_BACK)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, <reverse_power,0,0>);
            reverse = -1;
        }

        if(level & (CONTROL_RIGHT|CONTROL_ROT_RIGHT))
        {
            angular_motor.z -= speed / turning_ratio * reverse;
            angular_motor.x += 2;
            newRot = 0.1;
        }
        
        if(level & (CONTROL_LEFT|CONTROL_ROT_LEFT))
        {
            angular_motor.z += speed / turning_ratio * reverse;
            angular_motor.x -= 2;
    
            newRot = -0.1;
        }
    
        if (newRot != curRot)
        {
            //curRot = newRot;
            //llSetLinkPrimitiveParamsFast(3, [PRIM_ROT_LOCAL, llEuler2Rot(<PI/2, PI*(1+curRot), 0>)]);
        }
                
        if (moving>0 && !effects)
        {
            effects=1;
            psystem();
            llLoopSound("engine", 0.5);
        }
        else if (moving==0 && effects>0)
        {
            effects=0;
            stoppsystem();
        }

        llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, angular_motor);

    } //end control   
    
    timer()
    {
           
        
    }
    
} //end default

_________________________________________________

Thank you..

Link to comment
Share on other sites

Sitting on or standing up from an object causes the script inside to trigger its changed event (if present). That is where your script decides whether to request permissions from the sitting avatar and start the vehicle, or to disable itself. As currently written, the script basically only cares if the agent variable isn't equal to "NULL_KEY" (which is what happens when a previously seated avatar stands up). So if it currently accepts any non null key (i.e. any avatar) then to achieve the owner-only behavior, you would want to instead check if the agent variable is equal to the current owner. The function llGetOwner() can give you that, so change the check to see if the agent variable is equal to the output of llGetOwner().

if (agent == llGetOwner())

Unrelated, but I see several calls to llSetTimerEvent, yet the actual timer event itself is empty and therefore unnecessary. If you're not actually using the timer for anything, you can probably delete (or comment out) those functions.

  • Like 1
Link to comment
Share on other sites

Ah that did it. 👍

I was trying to add it in differently, However your way is far easier.. Just so no one else drives it away Smile.

As for timer part yes i understand what you are referring to.. That is in the original I was using it as a rez and die object (Ship).

When i was making a Rez a boat for other to uses so I just set the die timer to zero and left the timer stuff..Just so it stays alive for my private use.

I understand that i can take that timer stuff out and still may do that to make it tighter.

Want to thank you for your help it let my stop knocking my head against the wall ..LOL  🤪

Thanks so much your response was well appreciated.

 

Link to comment
Share on other sites

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