(2021-02-26, 01:37 AM)Z3fRaN Wrote: I don't have a good idea on how to make a top5 all time it, only thing I can think of is for(i=0;i<MAX_PLAYERS;i) but don't know how to continue the rest.
I can give you a code that gets top 5 online players, if you want it.
But to get the best players all the time you have to use MySQL:
(2021-02-26, 05:22 AM)Kwarde Wrote: If you're using MySQL you can very easily select a top 5 based on certain data. For example, let's say we have this users table:\
Code:+---+----------+------+-------+------ | id | name? ? ? | kills | deaths | score | +---+----------+------+-------+------ |? 1 | Kwarde? ? |? ? 16 |? ? 25 |? ? 4 | |? 2 | Playa? ? |? ? 2 |? ? 19 |? ? 1 | |? 3 | Z3fRaN? ? |? ? 28 |? ? ? 1 |? 100 | |? 4 | Narf3z? ? |? ? 1 |? ? 28 |? ? 0 | |? 5 | MathPi? ? |? ? 99 |? ? ? 0 |? ? 50 | |? 6 | Slayer? ? |? ? 66 |? ? 13 |? ? 25 | |? 7 | JimmyPage |? ? 0 |? ? ? 2 |? ? 0 | +---+----------+------+-------+------
Using this query:
Code:SELECT name, kills FROM users ORDER BY kills DESC LIMIT 5;
This would select columns "name" and "kills" from the table "users" and order by kills, descending (DESC -- ASC would order ascending, and thus beginning with the lowest values). LIMIT 5 says: Limit to 5 results. The query itself should be pretty clear.
This would give this output:
Code:+-------+------ | name? | kills | +-------+------ | MathPi |? ? 99 | | Slayer |? ? 66 | | Z3fRaN |? ? 28 | | Kwarde |? ? 16 | | Playa? |? ? 2 | +-------+------
