[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


Messages In This Thread
[SQL] Top 3 Players. - by Trevor19012 - 26.11.2017, 04:43
Re: [SQL] Top 3 Players. - by Kane - 26.11.2017, 04:46
Re: [SQL] Top 3 Players. - by xMoBi - 26.11.2017, 04:48
Re: [SQL] Top 3 Players. - by Trevor19012 - 26.11.2017, 04:52

Forum Jump:


Users browsing this thread: 1 Guest(s)