SA-MP Forums Archive
Get highest variables - 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)
+--- Thread: Get highest variables (/showthread.php?tid=516525)



Get highest variables - audriuxxx - 31.05.2014

Hi,

I do cikle max_vehicles and all vehicles have variable. And i want to know 10 vehicles where my variable is biggest. How to do that?


Re : Get highest variables - S4t3K - 31.05.2014

Get the variable of each vehicle and compare.

For example

PHP Code:

new var[10] = {9181254116, -384664253184};
new 
highest 0;
for(new 
0sizeof(var); i++)
{
      if(var[
i] > highesthighest = var[i];
      return 
1;
}
printf(highest); // Will display "64253" 



Re: Re : Get highest variables - Threshold - 01.06.2014

Quote:
Originally Posted by S4t3K
View Post
Get the variable of each vehicle and compare.

For example

PHP Code:

new var[10] = {9181254116, -384664253184};
new 
highest 0;
for(new 
0sizeof(var); i++)
{
      if(var[
i] > highesthighest = var[i];
      return 
1;
}
printf(highest); // Will display "64253" 
You were close.
pawn Code:
new highest = 0, var[10] = {9, 181, 254, 11, 6, -3, 846, 64253, 1, 84};
    for(new i = 0; i < sizeof(var); i++) highest = (var[i] > highest) ? (var[i]) : (highest);
    printf("d", highest); // Will display "64253"