[SQL] Top 3 Players.
#1

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
Reply
#2

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.
Reply
#3

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

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!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)