getting rank with sql function
#1

I want to get players rank by score from mysql.

example: John 5, Jones 4

Ant function would return John as #1.

Tryed:

pawn Код:
stock GetPlayerMYSQLrank(playerid)
{
    new str[20], Query[150];
    format(Query, sizeof(Query), "SELECT COUNT(user) AS rank FROM `playerinfo` WHERE score >= (SELECT score FROM playerinfo WHERE user = '%s')", pName(playerid));

    mysql_query(Query);
    mysql_store_result();
    if(mysql_retrieve_row())
    {
        mysql_fetch_field_row(str,"rank");
    }
    return strval(str);

}
it executes succesffuly, but latter in debug i can see CMySQLHandler::RetrieveRow() - You cannot call this function now. (Reason: Empty Result)
Reply
#2

Hm, I think I wrote that query. Could you screencap your playerinfo structure?
Reply
#3

I assume you already have an player enum with the values set already, just use that instead.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)