SA-MP Forums Archive
Need top 10 mysql +rep - 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: Need top 10 mysql +rep (/showthread.php?tid=581271)



Need top 10 mysql +rep - Izaki - 11.07.2015

need top 10 rank mysql

mysql version r39-2

+rep


Re: Need top 10 mysql +rep - SilentSoul - 11.07.2015

pawn Код:
mysql_tquery( mysql, "SELECT username, rank FROM `your database` ORDER BY `rank` DESC LIMIT 20", "LoadTopRank", "", "" );
This query will load the top 10 players, if you want to show them on dialog you should loop the rows.
pawn Код:
forward LoadTopRank( );
public LoadTopRank( )
{
    new
        name[24], rank, str[ 512 ];
    for(new i =0; i < cache_num_rows(); i++)
    {
        cache_get_field_content(i, "username", name, mysql, 24);
        kills = cache_get_field_content_int(i,"rank");
        deaths = cache_get_field_content_int(i,"deaths");
        format( str, sizeof( str ) , "%s %i) %s %i", str, i+1, name, rank);
    }
    ShowPlayerDialog( playerid, 2121, DIALOG_STYLE_MSGBOX,"Top",str, "Close","" );
}