![]() |
|
[Pawn] TOP 10 MySQL list - Printable Version +- open.mp forum (https://forum.open.mp) +-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) +--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) +--- Thread: [Pawn] TOP 10 MySQL list (/showthread.php?tid=2808) |
TOP 10 MySQL list - Blood - 2024-06-30 Hey, I was wondering if someone could help me out writing a code for displaying TOP 10 players by a parameter, for example top 10 with highest score. I know how to do it in the oldest MySQL, but I havent been around for some time and can't figure out how to do it with the newest version. This is my old code Code: mysql_query("SELECT `Score` ,`User` FROM `table` ORDER BY `Score` DESC LIMIT 10");
mysql_store_result();
new id,output[600], str[64];
while(mysql_retrieve_row())
{
id ++;
new username[24], scorevariable[5];
mysql_fetch_field_row(username, "Username");
mysql_fetch_field_row(scorevariable, "Score");
format(str,sizeof str, "%i. %s - %i score\n",id,username,strval(scorevariable));
strcat(output, str);
}
mysql_free_result();
ShowPlayerDialog(playerid,1945,0,"Score top list",output,"Close","");RE: TOP 10 MySQL list - PainFrenemy - 2024-07-28 PHP Code: CMD:check(playerid)
{
mysql_tquery(mysql, "SELECT `Score`, `User` FROM `table` WHERE `Score` != 0 ORDER BY `Score` DESC LIMIT 10", "ShowTOP10", "d", playerid);
}
forward ShowTOP10(playerid);
public ShowTOP10(playerid)
{
if(!cache_num_rows()) return 0;
new output[600];
static username[MAX_PLAYER_NAME];
for(new i, num = cache_num_rows(); i < num; i++)
{
cache_get_value_name(i, "Username", username);
cache_get_value_name_int(i, "Score", scorevariable);
format(output, sizeof(output), "%s%i. %s - %i score\n",output, i+1, username, scorevariable);
}
return ShowPlayerDialog(playerid,1945,0,"Score top list",output,"Close","");
}
|