Hey. Trying to switch from sqlite into mysql with this plugin. All good so far, but mysql doesn't exactly list the scores in "natural" descending order - this is how a "top10" command looks like:
1st player - 99 points
2nd player - 98 points
3rd player - 941 points
(!)
4th player - 94 points
etc...
I'm assuming the bit with STAT_SCORE here is the part (written for sqlite) that deals with the top10 listings. Any clue on how to make the top10 listings work with mysql database?
Code:
public TopCallback(const String:name[], const String:steamid[], any:stats[], any:data, index)
{
new Handle:pack = data;
ResetPack(pack);
new Handle:panel = Handle:ReadPackCell(pack);
new client = ReadPackCell(pack);
if(steamid[0] == 0) // last call
{
CloseHandle(pack);
SendPanelToClient(panel, client, TopHandler, 10);
CloseHandle(panel);
}
else
{
decl String:text[256];
if(index > 3)
{
Format(text, sizeof(text), "%i. %s - %.2f KD - %i points ",
index,
name,
float(stats[STAT_KILLS])/
(stats[STAT_DEATHS] == 0 ?
1.0 : float(stats[STAT_DEATHS])),
stats[STAT_SCORE] + g_start_points);
DrawPanelText(panel, text);
}
else
{
Format(text, sizeof(text), "%s - %.2f KD - %i points ",
name,
float(stats[STAT_KILLS])/
(stats[STAT_DEATHS] == 0 ?
1.0 : float(stats[STAT_DEATHS])),
stats[STAT_SCORE] + g_start_points);
DrawPanelItem(panel, text);
}
}
}
In mysql, something like this should work. Just no idea how to implement.
Code:
SELECT * FROM `players` ORDER BY `score` + 0 DESC LIMIT 10