SA-MP Forums Archive
MySQL R39 /top10 - 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 R39 /top10 (/showthread.php?tid=606634)



MySQL R39 /top10 - Sensation - 07.05.2016

How can i make /top10 system with mysql r39-3? Please help me.


Re: MySQL R39 /top10 - SyS - 07.05.2016

you can use ORDER BY statements for that purpose


Re: MySQL R39 /top10 - Sensation - 07.05.2016

I know it but how can i convert this code to mysql r39 version(cache)

Код:
mysql_query("SELECT score, username FROM usertable ORDER BY score DESC LIMIT 10");
mysql_store_result();
new id;
while(mysql_retrieve_row())
{
    id ++;
    new username[24], scorevariable[5];
    mysql_fetch_field_row(username, "username");
    mysql_fetch_field_row(scorevariable, "score");
    printf("Position %d: Username - %s | Score: %d", id, username, strval(scorevariable));
}
mysql_free_result();



Re: MySQL R39 /top10 - Jefff - 07.05.2016

pawn Код:
new Cache:result, rows;
result = mysql_query(connection_handle, "SELECT score, username FROM usertable ORDER BY score DESC LIMIT 10");
if((rows = cache_num_rows(result)))
{
    new id, score, username[MAX_PLAYER_NAME + 1];
    for(new i=0; i < rows; i++)
    {
        score = cache_get_row_int(i, 0);
        cache_get_row(i, 1, username);
        printf("Position %d: Username - %s | Score: %d", ++id, username, score);
    }
}
cache_delete(result);
you can use also mysql_tquery with callback