Get highest variables
#1

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?
Reply
#2

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" 
Reply
#3

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"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)