how to check variable is maximum
#2

I'm assuming you want to check who has the highest score on the server, no? If so, the following code can help you.
pawn Код:
GetHighestDMScore()
{
   new highscore, highcount, highID = INVALID_PLAYER_ID;
   for( new i = 0; i < MAX_PLAYERS; i ++ )
   {
      if( dmscore[ i ] > highscore )
      {
         highscore = dmscore[ i ];
         highID = i;
         highcount = 0;
      }
      else if( dmscore[ i ] == highscore )
      {
         highcount++;
         highID = INVALID_PLAYER_ID;
      }
   }

   if( count > 0 )
   {
      // Someone else, or more, had the same highest score
   }
   else if( highID == INVALID_PLAYER_ID )
   {
      // No one had a high score, or no players connected (most likely outcome)
   }
   else
   {
      // Person with the highest score is in the variable 'highID'
   }
}
Read the comments to determine where to put the code that you wish. Please note that this is also not tested, so you will be responsible for doing so.
Reply


Messages In This Thread
how to check variable is maximum - by jame42 - 21.11.2010, 06:57
Re: how to check variable is maximum - by Grim_ - 21.11.2010, 07:02
Re: how to check variable is maximum - by Lorenc_ - 21.11.2010, 07:02
Re: how to check variable is maximum - by jame42 - 21.11.2010, 07:12
Re: how to check variable is maximum - by Grim_ - 21.11.2010, 07:15
Re: how to check variable is maximum - by jame42 - 21.11.2010, 07:22

Forum Jump:


Users browsing this thread: 1 Guest(s)