SA-MP Forums Archive
How to get the highest var? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to get the highest var? (/showthread.php?tid=112274)



How to get the highest var? - Striker_Moe - 06.12.2009

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


Re: How to get the highest var? - dice7 - 06.12.2009

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



Re: How to get the highest var? - DeathOnaStick - 06.12.2009

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 :/