Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

Help with ORDER BY (MySQL)

$
0
0
Hey, I'm not the most advanced scripter, actually I've started scripting recently, and I don't know how can I resolve this problem: I want to make it so a player can see his position in the leaderboards, for example, "You are currently in position %d out of %d with %d score!", however I don't know how to get the players position in the leaderboard, everything else works fine. The code is below

Code:

CMD:yourpos(playerid, params[])
{
        new query[128];
        format(query, sizeof(query), "SELECT score, nick FROM playerdata ORDER BY score");
        mysql_query(query);
        mysql_store_result();
       
        new tmpstr[60], p;
       
       
                while(mysql_fetch_row(query))
                {               
                        mysql_fetch_field("nick", pInfo[playerid][Nick]);
                        mysql_fetch_int("score", pInfo[playerid][pScore]);
                       
                        p++;
                       
                        format(tmpstr, sizeof(tmpstr), "You are currently %d out of %d with %d score!", p, ReturnUserCount(), GetPlayerScore(playerid));
                        ShowPlayerDialog(playerid, 79, DIALOG_STYLE_MSGBOX, "{10F441}Your score..", tmpstr, "Close", "");
                       
                }
       
        return 1;
}


Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>