Jump to content

How would I make this vehicle publicly drivable?


Pullamies
 Share

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

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

Recommended Posts

The script is wonderful for making a simple vehicle.

But it now ejects anyone who is not the owner and doesnt enable controls.

I would like it to be 100% publicly drivable to anyone visiting my land.

Help?

 

integer CruiseMode; /// Lii
integer Crui;      /// Lii
///// Click Left and Right at the same time to toggle Cruise on/off  /// Lii



//Drifting Thoughts Car script with flight
//by Kayla Stonecutter
//
//


//Basic settings
list        ForwardPowerGears = [2, 4, 6, 8, 10, 20]; //Forward power for each gear, any number of gears. Jump/Crouch to change gears
float       ReversePower = -5; //Reverse power
float       TurnPower = 20; //Turning power   7
float       TurnSpeedAdjust = 0.0; // 1 how much effect speed has on turning, higher numbers effect more.  0.0 to disable

float       FlightForwardPower = 24; //Power for flight modes
float       FlightReversePower = -16;
float       FlightUpPower = 14;
float       FlightDownPower = -14;
float       FlightStrafePower = 12;
float       FlightTurnPower = 4;


string      SitText = "Drive"; //Text to show on pie menu
//string      NonOwnerMessage = ""; //Message when someone other than owner tries to sit

integer     ListenCh = 33333; //channel to listen for commands
string      HornCommand = "h"; //command to sound the horn
string      RevCommand = "r"; //command to rev the engine
string      IdleCommand = "start engine"; //command to start engine
string      StopCommand = "stop engine"; //command to stop engine
string      FlightCommand = "fly on"; //command to switch to flight mode
string      GroundCommand = "fly off"; //command to switch to ground mode

integer     EnableFlight = 0;//set to 0 to not allow flight mode

//You can leave Horn, Rev, and Startup sounds at "" to not use them. Idle, Run, and Flight must be filled (Idle and Run can be the same)
//sounds must either be the name of a sound in the contents, or a UUID. Horn and Rev sounds go with the Horn/Rev script in a different prim

string      FlightSound = "wind"; //Sound to play while flying
string      HornSound = "TAXI-HORN"; //Sound to play for horn
string      RevSound = "TAXI-RUN"; //Sound to play for engine rev
string      IdleSound = "TAXI-RUN"; //Sound to play when idling
string      RunSound = "TAXI-RUN"; //Sound to play when the gas in pressed
string      StartupSound = "TAXI-START"; //Sound to play when owner sits  
string      CollisionSound = ""; //Sound to play when colliding with something else

vector      SitTarget = <-0.02, 0.05, 0.23>; //Position relative to root to place driver
vector      SitRotation = <0, 0, 0>; //Rotation of the avatar, in degrees
string      DrivingAnim = "TAXI-DRIVE"; //Animation to play when owner sits, leave blank for no anim

//Other variables
key         Owner;
string      OwnerName;
float       ForwardPower;
integer     NumGears;
integer     Gear;
integer     NewSound;
string      Sound; 
integer     CurDir;
integer     LastDir;
integer     Forward;
vector      SpeedVec;
vector      Linear;
vector      Angular;
integer     Active;
key         sitting;
integer     Moving;
string      SimName;

integer     DIR_STOP = 100;
integer     DIR_START = 101;
integer     DIR_NORM = 102;
integer     DIR_LEFT = 103;
integer     DIR_RIGHT = 104;
integer     DIR_FLIGHT = 105;


default
{
    state_entry()
    {
        if(llGetInventoryType("DT Unpacker") == -1)
        {
            Owner = llGetOwner();
            OwnerName = llKey2Name(Owner);
            TurnSpeedAdjust *= 0.01;
            ForwardPower = llList2Integer(ForwardPowerGears, 0);
            NumGears = llGetListLength(ForwardPowerGears);
            llSetSitText(SitText);
            llCollisionSound(CollisionSound, 0.2);///sound
            llSitTarget(SitTarget, llEuler2Rot(SitRotation * DEG_TO_RAD));
            state Ground;
        }
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
}

state Ground
{
    state_entry()
    {
        Crui = CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT; /// Lii
        llListen(ListenCh, OwnerName, NULL_KEY, "");
        llStopSound();
        if(!Active)
        {
            llSetStatus(STATUS_PHYSICS, FALSE);
            llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
            llUnSit(llAvatarOnSitTarget());
        }else{
            SimName = llGetRegionName();
            llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
            llMessageLinked(LINK_ALL_CHILDREN, DIR_NORM, "", NULL_KEY);
            NewSound = 1;
            Sound = IdleSound;
            Linear = <0,0,-2>;
            Gear = 0;
            ForwardPower = llList2Integer(ForwardPowerGears, 0);
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON, TRUE, FALSE);
        }

        
                
                        
 
                                
                                                               
                                                                                              
                                               
                                                                              
                               
                                                              
                                                                                             
                                              
                                                                             
                                                                                                                                           
////  changer ca 

      
      
        llSetVehicleType(VEHICLE_TYPE_CAR);
        

        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1.0);
        
        //bracage   grand valeur = petit bracage, angle pourrave
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.1);
        
        
        
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.3);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
        
        
        //
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.22);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.0);
        
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <100.0, 2.0, 1.0> ); //100, 2, 1000
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1.0, 1.0, 1.0> ); //1000,1000,1000
        
        
        //0 bouncin, 1 not bouncing
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.9);
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.9);
        
        llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0 );
        llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.1 );
        llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 0 );
        llSetVehicleFloatParam(VEHICLE_BUOYANCY, -1.0 );
//**************************************************
        


//****************************************************
        
        
        
        
        
        llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
        
        llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP);
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(llGetOwnerKey(id) != Owner) return;
        message = llToLower(message);
        if((message == HornCommand) && (HornSound != "")) llMessageLinked(LINK_SET, 12345, HornSound, NULL_KEY);
        else if((message == RevCommand) && (RevSound != "")) llMessageLinked(LINK_SET, 12345, RevSound, NULL_KEY);
        else if(message == IdleCommand) llLoopSound(IdleSound, 0.5);///sound
        else if(message == StopCommand) llStopSound();
       
    }
    
    changed(integer change)
    {
        if((change & CHANGED_LINK) == CHANGED_LINK)
        {
            sitting = llAvatarOnSitTarget();
            if(sitting)
            {
                if(sitting != llGetOwner())
                {
                 //   llWhisper(0, NonOwnerMessage);
                    llUnSit(sitting);
                }else if(!Active)
                {
                    llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
                    if(StartupSound != "") llTriggerSound(StartupSound, 1.0);///sound
                    llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
                    llSetPos(llGetPos() + <0,0,0.15>);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    SimName = llGetRegionName();
                    llLoopSound(IdleSound, 0.5);///sound
                    llSetTimerEvent(0.1);
                    CurDir = DIR_NORM;
                    LastDir = DIR_NORM;
                }
            }else if(Active)
            {
                llSetTimerEvent(0.0);
                if(DrivingAnim != "") llStopAnimation(DrivingAnim);
                Active = 0;
                llStopSound();
                CruiseMode = FALSE; /// Lii
                llSetStatus(STATUS_PHYSICS, FALSE);
                llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
                llReleaseControls();
            }
        }
    }
    
    run_time_permissions(integer perms)
    {
        if(perms == (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA))
        {
            Active = 1;
            Gear = 0;
            Linear = <0,0,-2>;
            Angular = <0,0,0>;
            if(DrivingAnim != "")
            {
                llStopAnimation("sit");
                llStartAnimation(DrivingAnim);
            }
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT  |  CONTROL_LBUTTON, TRUE, FALSE);
            llSetCameraParams([
                CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
                CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
                CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds
                CAMERA_DISTANCE, 4.5, // ( 0.5 to 10) meters
                // CAMERA_FOCUS, <0,0,0>, // region-relative position
                //CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
                //CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
                //CAMERA_FOCUS_THRESHOLD, 0.5, // (0 to 4) meters
                CAMERA_PITCH, 30.0, // (-45 to 80) degrees   !!!!
                // CAMERA_POSITION, <0,0,0>, // region-relative position
                CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
                CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
                CAMERA_POSITION_THRESHOLD, 4.5, // (0 to 4) meters
                CAMERA_FOCUS_OFFSET, <0,0,0> // <-10,-10,-10> to <10,10,10> meters
            ]);
        }
    }
    
    control(key id, integer levels, integer edges)
    {
        if ((edges & levels & Crui) == Crui) {                      /// Lii
            CruiseMode = !CruiseMode;                              /// Lii
            if (CruiseMode){ llOwnerSay("CruiseMode Enabled"); }  /// Lii
            else {                                               /// Lii
                llOwnerSay("CruiseMode Disabled");              /// Lii
                Linear.x = 0.0;                                /// Lii
                NewSound = 1;                                 /// Lii
                Sound = IdleSound;                           /// Lii
            }                                               /// Lii
            return;                                        /// Lii
        }                                                 /// Lii
        if((edges & levels & CONTROL_LBUTTON))
        {
            llTriggerSound( HornSound, 1.0);
        }       
        
        if(!Moving)
        {
            Moving = 1;
            llSetStatus(STATUS_PHYSICS, TRUE);
        }
        
        SpeedVec = llGetVel() / llGetRot();
        
        if((edges & levels & CONTROL_UP))
        {
            if((Gear + 1) != NumGears)
            {
                ++Gear;
                llOwnerSay("Gear " + (string)(Gear + 1));
                ForwardPower = llList2Float(ForwardPowerGears, Gear);
                if(Linear.x > 0) Linear.x = ForwardPower;
            }
        }
        else if((edges & levels & CONTROL_DOWN))
        {
            if((Gear - 1) != -1)
            {
                --Gear;
                llOwnerSay( "Gear " + (string)(Gear + 1));
                ForwardPower = llList2Float(ForwardPowerGears, Gear);
                if(Linear.x > 0) Linear.x = ForwardPower;
            }
        }
        
        if((edges & levels & CONTROL_FWD))
        {
            Linear.x = ForwardPower;
            NewSound = 1;
            Sound = RunSound;
        }else if((edges & levels & CONTROL_BACK))
        {
            if (CruiseMode){
                Linear.x = 0.0;
                NewSound = 1;
                Sound = IdleSound;
            }
            else {
                Linear.x = ReversePower;
                NewSound = 1;
                Sound = RunSound;
            }
        }else if((edges & ~levels & CONTROL_FWD) || (edges & ~levels & CONTROL_BACK))
        {
            if (!CruiseMode){
                Linear.x = 0.0;
                NewSound = 1;
                Sound = IdleSound;
            }
        }
        //OK Aley. mouselook uses control inputs as CONTROL_LEFT and CONTROL_RIGHT. whereas 3rd person uses CONTROL_ROT_RIGHT etc. the original calls here were " if((levels & CONTROL_ROT_LEFT) > do this".... I changed it to " if (levels & (CONTROL_ROT_LEFT|CONTROL_LEFT))... this then allows both inputs. i replaced all the bits where needed as well.
        if(llFabs(SpeedVec.x) < 0.5)
        {
            if(levels & (CONTROL_ROT_LEFT|CONTROL_LEFT)) CurDir = DIR_LEFT;
            else if(levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT)) CurDir = DIR_RIGHT;
            else CurDir = DIR_NORM;
            Angular.z = 0.0;
        }else{
            if(SpeedVec.x < 0.0)
            {
                Forward = -1;
                SpeedVec.x *= -TurnSpeedAdjust;
            }else{
                Forward = 1;
                SpeedVec.x *= TurnSpeedAdjust;
            }
            
            if(levels & (CONTROL_ROT_LEFT|CONTROL_LEFT))
            {
                CurDir = DIR_LEFT;
                Angular.z = (TurnPower - SpeedVec.x) * Forward;
            }else if(levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT))
            {
                CurDir = DIR_RIGHT;
                Angular.z = -((TurnPower - SpeedVec.x) * Forward);
            }else if((edges & ~levels & (CONTROL_ROT_LEFT|CONTROL_LEFT)) || (edges & ~levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT)))
            {
                CurDir = DIR_NORM;
                Angular.z = 0;
            }
       
        }
    }
    
    moving_end()
    {
        if(llGetRegionName() == SimName)
        {
            Moving = 0;
            llSetStatus(STATUS_PHYSICS, FALSE);
        }else{
            SimName = llGetRegionName();
        }
    }
    
    timer()
    {
        if(Linear != <0.0,  0.0, -2.0> || CruiseMode)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, Linear);
            llApplyImpulse(Linear, TRUE);
        }
        if(Angular != <0.0, 0.0, 0.0>) llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, Angular);
        if(CurDir != LastDir)
        {
            llMessageLinked(LINK_ALL_CHILDREN, CurDir, "", NULL_KEY);
            LastDir = CurDir;
        }
        if(NewSound)
        {
            llStopSound();
            NewSound = 0;
            llLoopSound(Sound, 0.5);///sound
        }
    }
}

 

Edited by Pullamies
Typo
Link to comment
Share on other sites

There are a lot of annoying places that expect it to be owner only. none of them seem hard to fix, but it would be a tad tedious to debug.

main points for a quick hack-together fix:

  • replace all llOwnerSay("text"); with llRegionSayTo(llGetLinkKey(llGetNumberOfPrims()),0,"text"); or similar (could be more efficient with global variables).
  • replace llListen(ListenCh, OwnerName, NULL_KEY, ""); with llListen(ListenCh,"","","");
  • remove if(llGetOwnerKey(id) != Owner) return;
  • remove
    if(sitting != llGetOwner())
                    {
                     //   llWhisper(0, NonOwnerMessage);
                        llUnSit(sitting);
                    }else 
  • replace llRequestPermissions(Owner, with llRequestPermissions(sitting,
  • There may be other necessary changes in scripts in child prims.
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Quistess Alpha said:

There are a lot of annoying places that expect it to be owner only. none of them seem hard to fix, but it would be a tad tedious to debug.

main points for a quick hack-together fix:

  • replace all llOwnerSay("text"); with llRegionSayTo(llGetLinkKey(llGetNumberOfPrims()),0,"text"); or similar (could be more efficient with global variables).
  • replace llListen(ListenCh, OwnerName, NULL_KEY, ""); with llListen(ListenCh,"","","");
  • remove if(llGetOwnerKey(id) != Owner) return;
  • remove
    if(sitting != llGetOwner())
                    {
                     //   llWhisper(0, NonOwnerMessage);
                        llUnSit(sitting);
                    }else 
  • replace llRequestPermissions(Owner, with llRequestPermissions(sitting,
  • There may be other necessary changes in scripts in child prims.

Thank you so much!

Here is the revised script that doesn't make you fly off and is publicly drivable.

Just had to remove IllUnsit(sitting);

and instead of "Owner" have permissions trigger with "sitting".

Thanks!

 

integer CruiseMode; /// Lii
integer Crui;      /// Lii
///// Click Left and Right at the same time to toggle Cruise on/off  /// Lii



//Drifting Thoughts Car script with flight
//by Kayla Stonecutter
//
//


//Basic settings
list        ForwardPowerGears = [2, 4, 6, 8, 10, 20]; //Forward power for each gear, any number of gears. Jump/Crouch to change gears
float       ReversePower = -5; //Reverse power
float       TurnPower = 20; //Turning power   7
float       TurnSpeedAdjust = 0.0; // 1 how much effect speed has on turning, higher numbers effect more.  0.0 to disable

float       FlightForwardPower = 24; //Power for flight modes
float       FlightReversePower = -16;
float       FlightUpPower = 14;
float       FlightDownPower = -14;
float       FlightStrafePower = 12;
float       FlightTurnPower = 4;


string      SitText = "Drive"; //Text to show on pie menu
//string      NonOwnerMessage = ""; //Message when someone other than owner tries to sit

integer     ListenCh = 33333; //channel to listen for commands
string      HornCommand = "h"; //command to sound the horn
string      RevCommand = "r"; //command to rev the engine
string      IdleCommand = "start engine"; //command to start engine
string      StopCommand = "stop engine"; //command to stop engine
string      FlightCommand = "fly on"; //command to switch to flight mode
string      GroundCommand = "fly off"; //command to switch to ground mode

integer     EnableFlight = 0;//set to 0 to not allow flight mode

//You can leave Horn, Rev, and Startup sounds at "" to not use them. Idle, Run, and Flight must be filled (Idle and Run can be the same)
//sounds must either be the name of a sound in the contents, or a UUID. Horn and Rev sounds go with the Horn/Rev script in a different prim

string      FlightSound = "wind"; //Sound to play while flying
string      HornSound = "TAXI-HORN"; //Sound to play for horn
string      RevSound = "TAXI-RUN"; //Sound to play for engine rev
string      IdleSound = "TAXI-RUN"; //Sound to play when idling
string      RunSound = "TAXI-RUN"; //Sound to play when the gas in pressed
string      StartupSound = "TAXI-START"; //Sound to play when owner sits  
string      CollisionSound = ""; //Sound to play when colliding with something else

vector      SitTarget = <-0.02, 0.05, 0.23>; //Position relative to root to place driver
vector      SitRotation = <0, 0, 0>; //Rotation of the avatar, in degrees
string      DrivingAnim = "TAXI-DRIVE"; //Animation to play when owner sits, leave blank for no anim

//Other variables
key         Owner;
string      OwnerName;
float       ForwardPower;
integer     NumGears;
integer     Gear;
integer     NewSound;
string      Sound; 
integer     CurDir;
integer     LastDir;
integer     Forward;
vector      SpeedVec;
vector      Linear;
vector      Angular;
integer     Active;
key         sitting;
integer     Moving;
string      SimName;

integer     DIR_STOP = 100;
integer     DIR_START = 101;
integer     DIR_NORM = 102;
integer     DIR_LEFT = 103;
integer     DIR_RIGHT = 104;
integer     DIR_FLIGHT = 105;


default
{
    state_entry()
    {
        if(llGetInventoryType("DT Unpacker") == -1)
        {
            Owner = llGetOwner();
            OwnerName = llKey2Name(Owner);
            TurnSpeedAdjust *= 0.01;
            ForwardPower = llList2Integer(ForwardPowerGears, 0);
            NumGears = llGetListLength(ForwardPowerGears);
            llSetSitText(SitText);
            llCollisionSound(CollisionSound, 0.2);///sound
            llSitTarget(SitTarget, llEuler2Rot(SitRotation * DEG_TO_RAD));
            state Ground;
        }
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
}

state Ground
{
    state_entry()
    {
        Crui = CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT; /// Lii
        llListen(ListenCh, OwnerName, NULL_KEY, "");
        llStopSound();
        if(!Active)
        {
            llSetStatus(STATUS_PHYSICS, FALSE);
            llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
            llUnSit(llAvatarOnSitTarget());
        }else{
            SimName = llGetRegionName();
            llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
            llMessageLinked(LINK_ALL_CHILDREN, DIR_NORM, "", NULL_KEY);
            NewSound = 1;
            Sound = IdleSound;
            Linear = <0,0,-2>;
            Gear = 0;
            ForwardPower = llList2Integer(ForwardPowerGears, 0);
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_LBUTTON, TRUE, FALSE);
        }

        
                
                        
 
                                
                                                               
                                                                                              
                                               
                                                                              
                               
                                                              
                                                                                             
                                              
                                                                             
                                                                                                                                           
////  changer ca 

      
      
        llSetVehicleType(VEHICLE_TYPE_CAR);
        

        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_EFFICIENCY, 0.8);
        llSetVehicleFloatParam(VEHICLE_LINEAR_DEFLECTION_TIMESCALE, 1.0);
        
        //bracage   grand valeur = petit bracage, angle pourrave
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_EFFICIENCY, 0.2);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_DEFLECTION_TIMESCALE, 0.1);
        
        
        
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_TIMESCALE, 0.3);
        llSetVehicleFloatParam(VEHICLE_LINEAR_MOTOR_DECAY_TIMESCALE, 0.1);
        
        
        //
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_TIMESCALE, 0.22);
        llSetVehicleFloatParam(VEHICLE_ANGULAR_MOTOR_DECAY_TIMESCALE, 0.0);
        
        llSetVehicleVectorParam(VEHICLE_LINEAR_FRICTION_TIMESCALE, <100.0, 2.0, 1.0> ); //100, 2, 1000
        llSetVehicleVectorParam(VEHICLE_ANGULAR_FRICTION_TIMESCALE, <1.0, 1.0, 1.0> ); //1000,1000,1000
        
        
        //0 bouncin, 1 not bouncing
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_EFFICIENCY, 0.9);
        llSetVehicleFloatParam(VEHICLE_VERTICAL_ATTRACTION_TIMESCALE, 0.9);
        
        llSetVehicleFloatParam(VEHICLE_HOVER_HEIGHT, 0 );
        llSetVehicleFloatParam(VEHICLE_HOVER_EFFICIENCY, 0.1 );
        llSetVehicleFloatParam(VEHICLE_HOVER_TIMESCALE, 0 );
        llSetVehicleFloatParam(VEHICLE_BUOYANCY, -1.0 );
//**************************************************
        


//****************************************************
        
        
        
        
        
        llRemoveVehicleFlags( VEHICLE_FLAG_HOVER_TERRAIN_ONLY | VEHICLE_FLAG_HOVER_GLOBAL_HEIGHT);
        
        llSetVehicleFlags(VEHICLE_FLAG_NO_DEFLECTION_UP | VEHICLE_FLAG_LIMIT_ROLL_ONLY | VEHICLE_FLAG_HOVER_UP_ONLY | VEHICLE_FLAG_HOVER_WATER_ONLY | VEHICLE_FLAG_LIMIT_MOTOR_UP);
    }
    
    on_rez(integer param)
    {
        llResetScript();
    }
    
    listen(integer channel, string name, key id, string message)
    {
        if(llGetOwnerKey(id) != Owner) return;
        message = llToLower(message);
        if((message == HornCommand) && (HornSound != "")) llMessageLinked(LINK_SET, 12345, HornSound, NULL_KEY);
        else if((message == RevCommand) && (RevSound != "")) llMessageLinked(LINK_SET, 12345, RevSound, NULL_KEY);
        else if(message == IdleCommand) llLoopSound(IdleSound, 0.5);///sound
        else if(message == StopCommand) llStopSound();
       
    }
    
    changed(integer change)
    {
        if((change & CHANGED_LINK) == CHANGED_LINK)
        {
            sitting = llAvatarOnSitTarget();
            if(sitting)
            {
                if(!Active)
                {
                    llRequestPermissions(Owner, PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
                    if(StartupSound != "") llTriggerSound(StartupSound, 1.0);///sound
                    llMessageLinked(LINK_ALL_CHILDREN, DIR_START, "", NULL_KEY);
                    llSetPos(llGetPos() + <0,0,0.15>);
                    llSetStatus(STATUS_PHYSICS, TRUE);
                    SimName = llGetRegionName();
                    llLoopSound(IdleSound, 0.5);///sound
                    llSetTimerEvent(0.1);
                    CurDir = DIR_NORM;
                    LastDir = DIR_NORM;
                }
            }else if(Active)
            {
                llSetTimerEvent(0.0);
                if(DrivingAnim != "") llStopAnimation(DrivingAnim);
                Active = 0;
                llStopSound();
                CruiseMode = FALSE; /// Lii
                llSetStatus(STATUS_PHYSICS, FALSE);
                llMessageLinked(LINK_ALL_CHILDREN , DIR_STOP, "", NULL_KEY);
                llReleaseControls();
            }
        }
    }
    
    run_time_permissions(integer perms)
    {
        if(perms == (PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA))
        {
            Active = 1;
            Gear = 0;
            Linear = <0,0,-2>;
            Angular = <0,0,0>;
            if(DrivingAnim != "")
            {
                llStopAnimation("sit");
                llStartAnimation(DrivingAnim);
            }
            llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_DOWN | CONTROL_UP | CONTROL_RIGHT | CONTROL_LEFT | CONTROL_ROT_RIGHT | CONTROL_ROT_LEFT  |  CONTROL_LBUTTON, TRUE, FALSE);
            llSetCameraParams([
                CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
                CAMERA_BEHINDNESS_ANGLE, 0.0, // (0 to 180) degrees
                CAMERA_BEHINDNESS_LAG, 0.1, // (0 to 3) seconds
                CAMERA_DISTANCE, 4.5, // ( 0.5 to 10) meters
                // CAMERA_FOCUS, <0,0,0>, // region-relative position
                //CAMERA_FOCUS_LAG, 0.1 , // (0 to 3) seconds
                //CAMERA_FOCUS_LOCKED, FALSE, // (TRUE or FALSE)
                //CAMERA_FOCUS_THRESHOLD, 0.5, // (0 to 4) meters
                CAMERA_PITCH, 30.0, // (-45 to 80) degrees   !!!!
                // CAMERA_POSITION, <0,0,0>, // region-relative position
                CAMERA_POSITION_LAG, 0.1, // (0 to 3) seconds
                CAMERA_POSITION_LOCKED, FALSE, // (TRUE or FALSE)
                CAMERA_POSITION_THRESHOLD, 4.5, // (0 to 4) meters
                CAMERA_FOCUS_OFFSET, <0,0,0> // <-10,-10,-10> to <10,10,10> meters
            ]);
        }
    }
    
    control(key id, integer levels, integer edges)
    {
        if ((edges & levels & Crui) == Crui) {                      /// Lii
            CruiseMode = !CruiseMode;                              /// Lii
            if (CruiseMode){ llOwnerSay("CruiseMode Enabled"); }  /// Lii
            else {                                               /// Lii
                llOwnerSay("CruiseMode Disabled");              /// Lii
                Linear.x = 0.0;                                /// Lii
                NewSound = 1;                                 /// Lii
                Sound = IdleSound;                           /// Lii
            }                                               /// Lii
            return;                                        /// Lii
        }                                                 /// Lii
        if((edges & levels & CONTROL_LBUTTON))
        {
            llTriggerSound( HornSound, 1.0);
        }       
        
        if(!Moving)
        {
            Moving = 1;
            llSetStatus(STATUS_PHYSICS, TRUE);
        }
        
        SpeedVec = llGetVel() / llGetRot();
        
        if((edges & levels & CONTROL_UP))
        {
            if((Gear + 1) != NumGears)
            {
                ++Gear;
                llOwnerSay("Gear " + (string)(Gear + 1));
                ForwardPower = llList2Float(ForwardPowerGears, Gear);
                if(Linear.x > 0) Linear.x = ForwardPower;
            }
        }
        else if((edges & levels & CONTROL_DOWN))
        {
            if((Gear - 1) != -1)
            {
                --Gear;
                llOwnerSay( "Gear " + (string)(Gear + 1));
                ForwardPower = llList2Float(ForwardPowerGears, Gear);
                if(Linear.x > 0) Linear.x = ForwardPower;
            }
        }
        
        if((edges & levels & CONTROL_FWD))
        {
            Linear.x = ForwardPower;
            NewSound = 1;
            Sound = RunSound;
        }else if((edges & levels & CONTROL_BACK))
        {
            if (CruiseMode){
                Linear.x = 0.0;
                NewSound = 1;
                Sound = IdleSound;
            }
            else {
                Linear.x = ReversePower;
                NewSound = 1;
                Sound = RunSound;
            }
        }else if((edges & ~levels & CONTROL_FWD) || (edges & ~levels & CONTROL_BACK))
        {
            if (!CruiseMode){
                Linear.x = 0.0;
                NewSound = 1;
                Sound = IdleSound;
            }
        }
        //OK Aley. mouselook uses control inputs as CONTROL_LEFT and CONTROL_RIGHT. whereas 3rd person uses CONTROL_ROT_RIGHT etc. the original calls here were " if((levels & CONTROL_ROT_LEFT) > do this".... I changed it to " if (levels & (CONTROL_ROT_LEFT|CONTROL_LEFT))... this then allows both inputs. i replaced all the bits where needed as well.
        if(llFabs(SpeedVec.x) < 0.5)
        {
            if(levels & (CONTROL_ROT_LEFT|CONTROL_LEFT)) CurDir = DIR_LEFT;
            else if(levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT)) CurDir = DIR_RIGHT;
            else CurDir = DIR_NORM;
            Angular.z = 0.0;
        }else{
            if(SpeedVec.x < 0.0)
            {
                Forward = -1;
                SpeedVec.x *= -TurnSpeedAdjust;
            }else{
                Forward = 1;
                SpeedVec.x *= TurnSpeedAdjust;
            }
            
            if(levels & (CONTROL_ROT_LEFT|CONTROL_LEFT))
            {
                CurDir = DIR_LEFT;
                Angular.z = (TurnPower - SpeedVec.x) * Forward;
            }else if(levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT))
            {
                CurDir = DIR_RIGHT;
                Angular.z = -((TurnPower - SpeedVec.x) * Forward);
            }else if((edges & ~levels & (CONTROL_ROT_LEFT|CONTROL_LEFT)) || (edges & ~levels & (CONTROL_ROT_RIGHT|CONTROL_RIGHT)))
            {
                CurDir = DIR_NORM;
                Angular.z = 0;
            }
       
        }
    }
    
    moving_end()
    {
        if(llGetRegionName() == SimName)
        {
            Moving = 0;
            llSetStatus(STATUS_PHYSICS, FALSE);
        }else{
            SimName = llGetRegionName();
        }
    }
    
    timer()
    {
        if(Linear != <0.0,  0.0, -2.0> || CruiseMode)
        {
            llSetVehicleVectorParam(VEHICLE_LINEAR_MOTOR_DIRECTION, Linear);
            llApplyImpulse(Linear, TRUE);
        }
        if(Angular != <0.0, 0.0, 0.0>) llSetVehicleVectorParam(VEHICLE_ANGULAR_MOTOR_DIRECTION, Angular);
        if(CurDir != LastDir)
        {
            llMessageLinked(LINK_ALL_CHILDREN, CurDir, "", NULL_KEY);
            LastDir = CurDir;
        }
        if(NewSound)
        {
            llStopSound();
            NewSound = 0;
            llLoopSound(Sound, 0.5);///sound
        }
    }
}

 

Link to comment
Share on other sites

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