23.08.2012, 09:53
Well, if you don't mind using third party includes, using this: https://sampforum.blast.hk/showthread.php?tid=343172
you could outperform the code above at the cost of memory.
The code above is more or less pseudo code and probably doesn't work the way I wrote it but I am sure you get the picture =).
Regards.
you could outperform the code above at the cost of memory.
pawn Code:
new RichList[MAX_PLAYERS][2];
stock FindRichest()
{
RichList = {{0,0}...}; // Reset the array in case you only want online players to show up, u probs gotta rely on a loop there.. this doesn't work I am sure but you get the point.
foreach(new p : Player) // obv if u dont have foreach, yanno
{
RichList[p][0] = GetPlayerMoney(p);
RichList[p][1] = p;
}
SortDeepArray(RichList, 0);
// richest are:
RichList[200][1], RichList[199][1], RichList[198][1], RichList[197][1]
}
Regards.

