Fix an issue where !rank may show points of another player.

I hope this won't be a bad solution, but I commented the code with a solution just in-case!
This commit is contained in:
shavit 2017-10-24 06:23:08 +03:00
parent 3dc81c2112
commit ade4b001f8

View File

@ -868,8 +868,10 @@ void UpdatePlayerRank(int client)
if(GetClientAuthId(client, AuthId_Steam3, sAuthID, 32))
{
// if there's any issue with this query,
// add "ORDER BY points DESC " before "LIMIT 1"
char[] sQuery = new char[512];
FormatEx(sQuery, 512, "SELECT COUNT(*) rank, points FROM %susers WHERE points >= (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) ORDER BY points DESC LIMIT 1;",
FormatEx(sQuery, 512, "SELECT COUNT(*) rank, p.points FROM %susers u JOIN (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) p WHERE u.points >= p.points LIMIT 1;",
gS_MySQLPrefix, gS_MySQLPrefix, sAuthID);
gH_SQL.Query(SQL_UpdatePlayerRank_Callback, sQuery, GetClientSerial(client), DBPrio_Low);