[MySQL R40] Top 5 players - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [MySQL R40] Top 5 players (
/showthread.php?tid=618274)
[MySQL R40] Top 5 players -
ranme15 - 03.10.2016
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?
Re: [MySQL R40] Top 5 players -
Shinja - 03.10.2016
What is not working? btw this will give top 3 because you doing "LIMIT 3"
Re: [MySQL R40] Top 5 players -
ranme15 - 03.10.2016
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[]...)
Re: [MySQL R40] Top 5 players -
Konstantinos - 03.10.2016
Код:
"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.
Re: [MySQL R40] Top 5 players -
ranme15 - 03.10.2016
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