Raised This Month: $ Target: $400
 0% 

SoD Player Stats


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
IceCucumber
Member
Join Date: Dec 2011
Old 05-26-2013 , 06:30   Re: SoD Player Stats
Reply With Quote #10

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

Last edited by IceCucumber; 05-26-2013 at 06:43.
IceCucumber is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode