• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] How does one make a top5?
#11
Thank you all for help.



(2021-02-27, 11:45 PM)Radical Wrote:
(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 |



+-------+------



It's alright, I've done it with Y_INI, just need to test it for now.
  Reply


Messages In This Thread
How does one make a top5? - by Z3fRaN - 2021-02-26, 01:37 AM
RE: How does one make a top5? - by Virsenas - 2021-02-26, 02:18 AM
RE: How does one make a top5? - by Z3fRaN - 2021-02-26, 02:22 AM
RE: How does one make a top5? - by Virsenas - 2021-02-26, 04:24 AM
RE: How does one make a top5? - by Kwarde - 2021-02-26, 05:22 AM
RE: How does one make a top5? - by Virsenas - 2021-02-26, 11:54 AM
RE: How does one make a top5? - by Kwarde - 2021-02-27, 02:26 PM
RE: How does one make a top5? - by Virsenas - 2021-02-27, 08:43 PM
RE: How does one make a top5? - by arber - 2021-02-27, 11:30 PM
RE: How does one make a top5? - by Radical - 2021-02-27, 11:45 PM
RE: How does one make a top5? - by Z3fRaN - 2021-02-27, 11:55 PM

Forum Jump: