This is Orbiter:
Ok what is wrong?

I have start =0 at the beginning.
then this:

case OAPI_KEY_K: // start
        if (start=0)
                start=0;    
        else 
            PlayVesselWave3(MySoundID,START,NOLOOP,255,22100);
            start=1;
                    return 1;

So start should be 0 until K is pressed. If K is pressed then the wav is played and start =1

and this:

// engine sound
 double pit = (vsAirSpeed * pit2) + 11025;
 double sp = (190 +((vsAirSpeed)*5));
if (sp>=225)sp=225;
  sprintf(oapiDebugString(),"anim %2.2f", start );
if (start=1){PlayVesselWave3(MySoundID,ENG,LOOP,sp,pit);
}


if ((vsAirSpeed == 0) & (start==1)) { PlayVesselWave3(MySoundID,ENG,LOOP,190);
 
}                
}

so if start =1 vehicle is started after K was pressed. play wav
if start =0 not started skip
if start =1 (started) and VS =0 not moving play this wav
else nothing.
So unless it is started no wav should play.
the variable "double start=0 is set at thefirst. When I start the scenario. start shows up as 1 , before pressing K and I can press k and the start wav plays.
It compiles fine

line 2 in your first code snippet: use the boolean == operator instead of the assignment = operator.

lines 4-7 -- you need to use braces "='{' and '}' in order to put lines 5-7 inside the else block on line 4.

In the second code snippet its difficult to see what is going on because it is so poorly formatted.

Consider following the coding practice:
When you compare a const with a non-const for equality put const on LHS instead of RHS.

E.g.

//instead of this:
if ( start == 0 )
//do this:
if ( 0 == start )
case OAPI_KEY_K: // start
                    if (0 ==start); 
                            start=0;
                    else
                    {PlayVesselWave3(MySoundID,START,NOLOOP,255,22100);
                    start=1;}
                    return 1;

now I get this:

Chariotsound3.cpp(965) : error C2181: illegal else without matching if

Now what?

> Terminated with exit code 2.c2181 illegal case

line 2 in your first code snippet: use the boolean == operator instead of the assignment = operator.

lines 4-7 -- you need to use braces "='{' and '}' in order to put lines 5-7 inside the else block on line 4.

In the second code snippet its difficult to see what is going on because it is so poorly formatted.

that switch statement you posted doesn't make any sense. If start is 0 why set it to 0 again ? Can start be anything other than 0 or 1 (such as can it ever be 2) ? If not then how does it get set to 1?

I did thatbecause it worked. Any ideas. for another way.

What I want to happen is:
the letter K is pressed
if start =0 then play the start wav and set start to 1. So that that wav will not play again. if start=1 than it is started

>>I did thatbecause it worked
no it doesn't. This is how it should have been coded

case OAPI_KEY_K: // start
       if (0 ==start) 
      {
             PlayVesselWave3(MySoundID,START,NOLOOP,255,22100);
             start=1;
      }
      else
      {
              start = 0;
      }
      return 1;

how about this:

case OAPI_KEY_I: // forward
        gear=1;
        return 1;
        
        case OAPI_KEY_M: // reverse
        gear=-1;
        return 1;

the value for gear changes when the key is pressed but then goes back to 0. I have tried putting brackets around the gear= but no change

I thought that also. But check all references to gear. Here they are, they are mainly if gear=....

sprintf(oapiDebugString(),"gear %2.2f", thr );

    SetThrusterGroupLevel (THGROUP_ATT_YAWLEFT, thr);
    SetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT, thr);

if (gear=-1) 
    {
    SetThrusterGroupLevel (THGROUP_ATT_YAWLEFT, thr);
    SetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT, thr);
}
if (gear=0) 
    {
    SetThrusterGroupLevel (THGROUP_ATT_YAWLEFT, 0);
    SetThrusterGroupLevel (THGROUP_ATT_YAWRIGHT, 0);    
}       
    //Anim Levers
    
    // Forward LEFT Lever animation
    
    if (gear=-1)
    
    {
        i2=i2 + 0.01;
        if (i2 > .75) i2= .75;
        
        SetAnimation (anim_leverleft, i2);
        
        
    }
    
    
       
        if (gear=1)
    
    {
        i2=i2 - 0.01;
        if (i2 < 0.25) i2= 0.25;
        
        
        SetAnimation (anim_leverleft, i2);
        
        
    }
    
    
    if (gear=0)   
    {
        i2 = 0.5;
       
        
        
        SetAnimation (anim_leverleft, i2);
        
        
    }
        // Forward RIGHT Lever animation
    
    if (gear=-1)
    
    {
        i4=i4 + 0.01;
        if (i4 > .75) i4= .75;
        
        SetAnimation (anim_leverright, i4);
        
        
    }
    
    
       
        if (gear=1)
    
    {
        i4=i4 - 0.01;
        if (i4 < 0.25) i4= 0.25;
        
        
        SetAnimation (anim_leverright, i4);
        
        
    }
    
    
    if (gear=0)
    
    {
        i4 = 0.5;
       
        
        
        SetAnimation (anim_leverright, i4);
        
        
    }

I have run into this:

if (GetThrusterLevel (th_main) >0 && i3 == 0)
 {
    
    if (i > 1)i=0;
    
    if (vsAirSpeed > 0.15) {
        
        if (vsAirSpeed > 55) vsAirSpeed = 55;

    
    if (i > 1)i=0;
    i = i + (vsAirSpeed /3);
     
    if (vsAirSpeed ==0) i=0;
    
    sprintf(oapiDebugString(),"anim %2.2f", i );
    
    SetAnimation (anim_wheelright, i);
    SetAnimation (anim_wheelleft, i);
    
    main_on = 1;
    retro_on = 0;

what is to happen if thrust level is more than 0 the value I is added. but what happens is even though the thrust level is above 0 , I is increased only once. Rather than keepin increasing til it gets to 1

Thanks that fixed that part.

case OAPI_KEY_K: // start
       if (0 ==start) 
      {
             PlayVesselWave3(MySoundID,START,NOLOOP,255,22100);
             start=1;
      }
      else
      {
              start = 0;
      }
      return 1;

Okay I think this is right but the value for STart is always 1 not 0 until k is pressed

This question has already been answered. Start a new discussion instead.