[MySQL R40] Top 5 players
#1

ay

Код:
if(!strcmp(cmd, "/top", true))
{
    new query[128];
    mysql_format(SQL, query, sizeof(query), "SELECT * FROM `users` ORDER BY 'score' DESC LIMIT 3");
    mysql_tquery(SQL, query, "ScoreTopFive", "i", playerid);
    return 1;
}

forward ScoreTopFive(playerid);
public ScoreTopFive(playerid)
{
    new string[128];
    new name[25], score;

    for(new i = 0; i < rows; i ++)
    {
	    cache_get_value_name(i, "username", name);
	    cache_get_value_int(i, "score", score);

    	    format(string, 128, "%d. %s - %d", i+1, name, score);
    	    SendClientMessage(playerid, -1, string);
    }
    return 1;
}
This isn't working. Anyone that is familliar with the new MySQL versions enough to make this work?
Reply
#2

What is not working? btw this will give top 3 because you doing "LIMIT 3"
Reply
#3

Quote:
Originally Posted by Shinja
Посмотреть сообщение
What is not working? btw this will give top 3 because you doing "LIMIT 3"
Yeah my bad I intented to top 3. And this is just showing the top 3 rows' data at the database's table (with no regarding to the score).

btw, I forgot to quote this line:
Код:
new rows = cache_num_rows();
(under new name[]...)
Reply
#4

Код:
"SELECT * FROM `users` ORDER BY 'score' DESC LIMIT 3"
It takes score as text so no sorting is done. The correct would be `score` or without grave accent character around.

Two more things:
- You don't need to format, just use the query directly in mysql_tquery function.
- Don't select all the data but only username and score columns.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Код:
"SELECT * FROM `users` ORDER BY 'score' DESC LIMIT 3"
It takes score as text so no sorting is done. The correct would be `score` or without grave accent character around.

Two more things:
- You don't need to format, just use the query directly in mysql_tquery function.
- Don't select all the data but only username and score columns.
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)