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?
 
ozoCommented:
 if (cvar->FindVar("mat_fullbright")->GetInt() == 1){//is it on?
  //**Error here**
 }else ( cvar->FindVar("mat_fullbright")->SetValue(0));//well turn it off.
0
 
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
0
 
B1-66ERCommented:
Hi  amckern.
before else must be ';':

if (cvar->FindVar("mat_fullbright")->GetInt() == 1) ; else ( cvar->FindVar("mat_fullbright")->SetValue(0));
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 :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.