10.12.2014, 12:59
Replace 'ARRAY' in the code below with the array you use. If the values you want to compare are floats, replace 'new HighestValue;' with 'new Float:HighestValue;'.
Edit: after reading your post again I now know what you mean.
This should do it:
pawn Код:
new HighestID = -1;
new HighestValue;
for(new i; i<sizeof(ARRAY); i++)
{
if(ARRAY[i] > HighestValue)
{
HighestID = i;
HighestValue = ARRAY[i];
}
}
//now you have the highest id and highest value.
This should do it:
pawn Код:
new HighestID = -1;
new Float:HighestValue, Float:X, Float:Y, Float:Z;
for(new i; i<MAX_PLAYERS; i++)
{
GetPlayerPos(i, X, Y, Z);
if(Z > HighestValue)
{
HighestID = i;
HighestValue = Z;
}
}
// Player 'HighestID' is the highest at "Z = HighestValue"
//Note: This code does not deal with a tie... if 2 players are at exactly the same height, the player with the lowest playerID will 'win'.

