help - How do I do this?
#2

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;'.

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.
Edit: after reading your post again I now know what you mean.
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'.
Reply


Messages In This Thread
help - How do I do this? - by _Application_ - 10.12.2014, 12:51
Re: help - How do I do this? - by Schneider - 10.12.2014, 12:59
Re: help - How do I do this? - by _Application_ - 10.12.2014, 13:30
Re: help - How do I do this? - by Schneider - 10.12.2014, 13:35

Forum Jump:


Users browsing this thread: 1 Guest(s)