SA-MP Forums Archive
[SQL] Top 3 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: [SQL] Top 3 Players. (/showthread.php?tid=645382)



[SQL] Top 3 Players. - Trevor19012 - 26.11.2017

Hi there. I am currently trying to make a leaderboard kind of thing, so I thought I'd start small with some tutorials here. Anyways, the system I have works fine to collect the descending order, but it does not tell the score, it tells the names though. Here is my code.

pawn Код:
COMMAND:top10(playerid, params[])
{
    new query[128];
    mysql_format(connection, query, sizeof(query), "SELECT name, Score FROM `rfs_accounts` ORDER BY `Score` DESC LIMIT 3");
    mysql_tquery(connection, query, "ScoreThree", "i", "playerid");
    return 1;
}
forward ScoreThree(playerid);
public ScoreThree(playerid)
{
    new string[128];
    new name[25], score;
    new rows = cache_num_rows();
    for(new i = 0; i < rows; i ++)
    {
        cache_get_field_content(i, "name", name);
        cache_get_field_content_int(i, "Score", score);

            format(string, 128, "%d. %s - %d", i+1, name, score);
            SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Basically, itll say
1. Trevor - 0 (When database score is 159)
2. Trevor1 - 0 ( When DB score 10)
3. Trevor 2 - 0 (When same as 2)

Any help is always appreciated


Re: [SQL] Top 3 Players. - Kane - 26.11.2017

Because you're using cache_get_field_content_int incorrectly.

Example usage:
PHP код:
new int_dest cache_get_field_content_int(2"money");
printf("The value in the third row and in the field 'money' is '%d'."int_dest); 
cache_get_field_content_int has 3 arguments. The 3rd one is for the connection handle, not the variable to store it in.


Re: [SQL] Top 3 Players. - xMoBi - 26.11.2017

is it possible to select two or more columns and order them according to selected columnss?


Re: [SQL] Top 3 Players. - Trevor19012 - 26.11.2017

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
Because you're using cache_get_field_content_int incorrectly.

Example usage:
PHP код:
new int_dest cache_get_field_content_int(2"money");
printf("The value in the third row and in the field 'money' is '%d'."int_dest); 
cache_get_field_content_int has 3 arguments. The 3rd one is for the connection handle, not the variable to store it in.
Thank you very much!!! I truly appreciate the help!