Getting a players ranking in a MySQL database.

Discussion in 'Plugin Development' started by WolfMage1, Jul 8, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    WolfMage1

    Currently, I have a MySQL database containing a bunch of fields (points, kills, deaths etc...) and I want to get the players ranking in that database (ordered by kills), How would I go about doing this without downloading all the data in MySQL and finding their ranking that way
     
  2. Offline

    ArsenArsen

    Well you can only take all of the fields and arrange them. Do this in an Async task to go around the fact that the server would crash if you didnt. And don't do it every time the ranking is needed, cache it.
     
  3. @WolfMage1 This is an easy MySql query.
    SELECT * FROM table ORDER BY kills DESC

    @ArsenArsen Or just get them ordered already and store them ;) #MySqlQueries
     
  4. Offline

    ArsenArsen

    Im not great with MySQL. Teach me allmighty @bwfcwalshy !
     
  5. Offline

    WolfMage1

    I already have that bit, just getting their ranking in it.
    Rank: 152 (example)
     
  6. Offline

    ArsenArsen

    *guesses* The first one in the reply should be rank 1? Right? So just get the position 152. Right?
     
  7. Offline

    WolfMage1

    I do /stats WolfMage1

    in chat it shows

    Kills: 54
    Deaths: 12
    blah blah....
    Rank: ?

    how would I get their ranking in the database,
     
  8. Offline

    WolfMage1

  9. Offline

    ArsenArsen

    Go through the reply one by one, and check do the UUIDs match. If they do, the index in the array + 1 is the ranking.

    EDIT: Im terrible -_-
     
Thread Status:
Not open for further replies.

Share This Page