Get the highest number of 150 numbers.
#1

Anyone know a function or a library who did it??

I wanna do some like this.

Код:
enum E_MYENUM
{
    VarTime,
    .....
    AnotherVar,
}
new Example[151][E_MYENUM];

public OnGameModeInit()
{
    for(new i = 1; i<= 151; i++)
    {
         Exemple[i][VarTime] = random(400);
    }
    return 1;
}

forward GetMaxNumber();
public GetMaxNumber()
{
     //This should be the function i need. I want the function return then highest number from Exemple->VarTime.
}
Hope u understood what i mean and help me, ty.
Reply
#2

Here you go!

PHP код:
GetMaxNumber()
{
    new 
highest Example[0][VarTime];
    for(new 
1isizeof(Example); i++)
    {
        if(
Example[i][VarTime] > highest)
            
highest Example[i][VarTime];
    }
    return 
highest;

please fix this
Код:
 for(new i = 1; i< 151; i++)
    {
         Exemple[i][VarTime] = random(400);
    }
Reply
#3

Quote:
Originally Posted by Eoussama
Посмотреть сообщение
Here you go!

PHP код:
GetMaxNumber()
{
    new 
highest Example[0][VarTime];
    for(new 
1isizeof(Example); i++)
    {
        if(
Example[i][VarTime] > highest)
            
highest Example[i][VarTime];
    }
    return 
highest;

please fix this
Код:
 for(new i = 1; i< 151; i++)
    {
         Exemple[i][VarTime] = random(400);
    }
Ty so much mate.
Reply
#4

No need for looping, you set the variable yourself, not the server. Make a new variable and update it with the highest number once set, so for example:

pawn Код:
new max_time_var, max_time_var_var;
...
Example[0][VarTime] = random(400);
if(Example[0][VarTime] > max_time_var)
{
       max_time_var = Example[0][VarTime];
       max_time_var_var = 0;
}
This is another way of doing it, just a friendly suggestion.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)