How to get the highest var?
#1

Title says it all, Iґve got the var kills[MAX_PLAYERS] and want to find the person with the most kills out.
Reply
#2

pawn Код:
new max;
for(new idx = 0; idx < MAX_PLAYERS; idx++)
{
  if(kills[idx] > max)
  {
    max = kills[idx];
  }
}
Reply
#3

Create a loop... Like this:

pawn Код:
new Mkillsid=0;
for(new i=0; i<=MAX_PLAYERS; i++)if(IsPlayerConnected(i))if(kills[i]>kills[Mkillsid])Mkillsid=i;
The playerid with highest number of kills will be stored in the variable Mkillsid.

Cheers.

#Edit#: Sry 2 late :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)