Code:
stock highest_number(numbers[], size, index=0) {
new i, highest, indexNum;
for(i=0;i<size;i++) {
if(numbers[i] > highest) {
highest = numbers[i];
indexNum = i;
}
}
if(index)
return indexNum;
else
return highest;
}
Example:
Code:
new players[32];
players[1] = 3;
players[2] = 7;
players[3] = 12;
players[4] = 16;
playerWithMostFrags = highest_number(players,32,1);
playerWithMostFrags in this case would be 4 (the index). If the last parameter was a 0 it would be 16 (the number).
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS