illegal else without matching if

Hi

I have a small problem --- illegal else without matching if --- this is part of --- if( pPlayer->IsSprinting() )




//-----------------------------------------------------------------------------
// CalcTotalAimModifier
//
// Calc the aim penalty scale factor based on the current
// player equipment and movement state
//-----------------------------------------------------------------------------
float CNDBaseBulletWeapon::CalcTotalAimModifier()
{
      CNDPlayer *pPlayer = ToNDPlayer( GetOwner() );
      if (!pPlayer)
            return 1.0f;

      // reset
      float fTotalAimModifier = 1.0f;

      const Vector & vecSpeed = pPlayer->GetLocalVelocity();
      #define SPEED_TOLERANCE 0.1f

      int flags = pPlayer->GetFlags();
      if( flags & FL_ONGROUND )
      {
            if( flags & FL_DUCKING )
                  fTotalAimModifier *= GetAimModifierCrouched();

            // Is player currently in motion?
            if( abs(vecSpeed.x) > SPEED_TOLERANCE ||
                  abs(vecSpeed.y) > SPEED_TOLERANCE ||
                  abs(vecSpeed.z) > SPEED_TOLERANCE )
            {
                  if( pPlayer->IsSprinting() )
                  {      
                        static bool bDisplayed = false;
                        
                        if( bDisplayed )
                        {
                              // turn it off
                              // Deactivate the 'light'
                              cvar->FindVar("mat_fullbright")->SetValue(0);
                        }
                        else
                        {
                              // turn it on
                              // Activate the 'light'
                              cvar->FindVar("mat_fullbright")->SetValue(1);
                        }
                        
                        bDisplayed = !bDisplayed;
                        
                        //check if the gun is down or not
                        if (cvar->FindVar("mat_fullbright")->GetInt() == 1)//is it on?
//**Error here**      else ( cvar->FindVar("mat_fullbright")->SetValue(0));//well turn it off.

                  }
                        //fTotalAimModifier *= GetAimModifierSprinting();
                  else if( pPlayer->IsWalking() )
                        fTotalAimModifier *= GetAimModifierWalking();
                  else
                        fTotalAimModifier *= GetAimModifierRunning();
            }
      }
      else // player's jumping or in the air
      {
            fTotalAimModifier *= GetAimModifierJumping();
      }

      return fTotalAimModifier;
}









This works by its self


if (cvar->FindVar("mat_fullbright")->GetInt() == 1)//is it on?
      DevMsg("World is bright!\n");
else( cvar->FindVar("mat_fullbright")->SetValue(0));//well turn it off.
      DevMsg("End Of do da\n");




What am I doing wrong?
LVL 2
amckernAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Sys_ProgCommented:
>>else ( cvar->FindVar("mat_fullbright")->SetValue(0));//well turn it off.

There are extra parenthesis here. No '(' required after else and no ')' before ;

HTH
Amit
ozoCommented:
 if (cvar->FindVar("mat_fullbright")->GetInt() == 1){//is it on?
  //**Error here**
 }else ( cvar->FindVar("mat_fullbright")->SetValue(0));//well turn it off.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
B1-66ERCommented:
Hi  amckern.
before else must be ';':

if (cvar->FindVar("mat_fullbright")->GetInt() == 1) ; else ( cvar->FindVar("mat_fullbright")->SetValue(0));
amckernAuthor Commented:
Thank you to you both, i made the accepted answer at the first one that worked - sorry that you got no points B1 - but i can see how your answer would have worked now :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.