SA-MP Forums Archive
getting rank with sql function - 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: getting rank with sql function (/showthread.php?tid=568579)



getting rank with sql function - ajwar - 23.03.2015

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)


Re: getting rank with sql function - Misiur - 23.03.2015

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


Re: getting rank with sql function - Jimmy0wns - 23.03.2015

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