Top players(MySQL)
#2

pawn Код:
stock LoadTop10()
{
    new Query[128];
    mysql_format(mysql, Query, sizeof(Query), "SELECT * FROM `players` ORDER BY `score` DESC LIMIT 10 "); //not tested, might need to fix the query
    mysql_function_query(mysql, Query, false, "LoadScores", "", ""); //init the load scores function with no cache
    return 1; // returning the function true
}


public LoadScores()
{
    new rows, fields;
    cache_get_data(rows, fields, mysql); //returning all 10 players & all their rows/fields
    if(rows)//if there are rows to be retrived continue
    {
        for(new i = 0; i < rows; i++) //loop through all the found rows and pull the following
        {
            new dest[24], score;
            cache_get_row(i, "pName", dest); //get all the player names pulled from the query
            score = cache_get_row_int(i, "score"); //pull all the scores from the rows retrived
            printf("top 10 players are %s wtih scores of %d", dest, scores); //print the result when ever LoadScores is called.
        }
        else
        {
            printf("There are no players saved with score.."); //if there were no rows found in the query called in LoadTop10
            //escape ect..
    }
    return 1;
}
Not tested or anything but you should get the basic idea.
(also idk why the formatting fucked up but w/e.
Reply


Messages In This Thread
Top players(MySQL) - by Problems - 28.06.2016, 13:33
Re: Top players(MySQL) - by Flake. - 28.06.2016, 13:52
Re: Top players(MySQL) - by Konstantinos - 28.06.2016, 14:06
Re: Top players(MySQL) - by Problems - 28.06.2016, 14:08
Re: Top players(MySQL) - by Konstantinos - 28.06.2016, 14:12

Forum Jump:


Users browsing this thread: 1 Guest(s)