Mysql LeaderBoard - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql LeaderBoard (
/showthread.php?tid=273787)
Mysql LeaderBoard -
Lefon - 03.08.2011
Hello, i try'ed to make a script, leaderboard, score
Like you writting a command /top
1 Name %i Score
2 Name %i Score
3 Name %i Score
top 10
anyone have, i need a MySQL one :/
Thanks
Re: Mysql LeaderBoard -
Vince - 03.08.2011
Code:
SELECT Name,Score FROM Users ORDER BY Score DESC LIMIT 10;
Then it's just a matter of doing mysql_fetch_row, etc, but I suppose you know how to do that.
Re: Mysql LeaderBoard -
Lefon - 03.08.2011
Nop, i don't know how count score table
from who have the most, and the less
Re: Mysql LeaderBoard -
GangsTa_ - 03.08.2011
https://sampforum.blast.hk/showthread.php?tid=269610
I guess this one has a top list, even an UCP and made with PHP, etc.
Re: Mysql LeaderBoard -
[HiC]TheKiller - 03.08.2011
pawn Code:
mysql_query("SELECT `username` FROM `table` ORDER BY `score` DESC LIMIT 10");
mysql_store_result();
new num;
new top[10][24];
while(mysql_retrieve_row())
{
mysql_fetch_field_row(top[num], "username");
num++;
}
mysql_free_result();
printf("Rank 1: %s, Rank 2: %s, Rank 3: %s, Rank 4: %s, Rank 5: %s, Rank 6: %s, Rank 7: %s, Rank 8: %s, Rank 9: %s, Rank 10: %s", top[0], top[1], top[2], top[3], top[4], top[5], top[6], top[7], top[8], top[9]);
Think that's right, it's late and I'm pretty tired. Replace those field names with yours
.
Re: Mysql LeaderBoard -
Lefon - 03.08.2011
It work's but how tu make "Showing Name And Hes Score
Re: Mysql LeaderBoard -
[HiC]TheKiller - 04.08.2011
pawn Code:
mysql_query("SELECT username, score FROM `table` ORDER BY `score` DESC LIMIT 10");
mysql_store_result();
new num, top[10][24], score[10][10];
while(mysql_retrieve_row())
{
mysql_fetch_field_row(top[num], "username");
mysql_fetch_field_row(score[num], "score");
num++;
}
mysql_free_result();
printf("Rank 1: %s with %d score, Rank 2: %s with %d score , Rank 3: %s with %d score, Rank 4: %s with %d score, Rank 5: %s with %d score, Rank 6: %s with %d score, Rank 7: %s with %d score, Rank 8: %s with %d score, Rank 9: %s, Rank 10: %s with %d score", top[0], score[0], top[1], strval(score[1]), top[2], strval(score[2]), top[3], strval(score[3]), top[4], strval(score[4]), top[5], strval(score[5]), top[6], strval( score[6]), top[7], strval(score[7]), top[8], strval(score[8]), top[9], strval(score[9]));