Raised This Month: $ Target: $400
 0% 

Need help for a top15 code (specially on sorting part)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 06-03-2010 , 02:02   Need help for a top15 code (specially on sorting part)
Reply With Quote #1

Hi,

Well, nothing... i am doing a surf plugin, but i had some problems and doubts of top15 part... specially on the sorting, i saw a lot of plugin with top15 system but... didn't understand at all, the part of sorting the records (best time first, then second, etc...)

I am using a method with the native SortStrings, and i am posting here becouse i don't know if is a good method... and if you correct me others things about the top15 code, would be good to.

The code is not completed, but well... here is it:

PHP Code:
SaveRecord(id, const name[], Float:Timeweapon)
{    
    if(
fBestTime[id] != 0.0)
    {
        if(
Time >= fBestTime[id])
            return;
    }
    
    
//get_mapname(mapName, 31);
    
new topPath[192];
    
GetFile(topPathTOP_15);
    
    if(!
dir_exists(topPath) )
        
mkdir(topPath);
    
    
format(topPath191"%s/%s_%s.cfg"topPathProRecord[id] ? "pro" "nub"mapName);
    
    if(!
file_exists(topPath) )
        
fclose(fopen(topPath"wt") );
    
    static 
szSteam[32], szDate[32];
    
get_user_authid(idszSteam31);
    
get_time("%m/%d/%Y"szDate31);
    
    static 
szData[256];
    
    if(!
fBestTime[id])
    {
        
formatex(szData127"^"%f^" ^"%s^" ^"%s^" ^"%s^" ^"%d^" ^"%s^" ^"%s^" ^n"TimeszSteamnameWeaponsName[weapon], gGocheckCount[id], "country"szDate);
        
write_file(topPathszData);
        return;
    }
    
    if(
Time fBestTime[id])
    {    
        static 
oldTime[12], getSteam[32], iLine 0iLen 0;
        
        while(
read_file(topPathiLineszData255iLen) )
        {
            if(
szData[0] == ';' || szData[1] == '/' && szData[1] == '/' || !iLen)
                continue;
            
            
parse(szDataoldTime11getSteam31);
            
            if(
equal(getSteamszSteam) )
            {
                
formatex(szData255"^"%f^" ^"%s^" ^"%s^" ^"%s^" ^"%d^" ^"%s^" ^"%s^" ^n"TimeszSteamnameWeaponsName[weapon], gGocheckCount[id], "country"szDate);
                
write_file(topPathszDataiLine);
                break;
            }
            
            
iLine++;
        }
    }
    
    if(
file_size(topPath1) > 1)
        
SortTop15(topPath);
    
    return;
}

SortTop15(const FileName[])
{
    static 
szLine[256], iLineiLenincrement;
    
    while(
read_file(FileNameiLine++, szLine255iLen) )
    {
        if(!
strlen(szLine) ) continue;
        
        
copy(SaveTop15[increment], 255szLine);
        
        
increment++;
    }
    
    
SortStrings(SaveTop1515Sort_Descending);
    
    
delete_file(FileName);
    
    for(new 
0incrementi++)
    {
        
formatex(szLine255"%s"SaveTop15[i]);
        
write_file(FileNameszLine);
    }
}

LoadRecord(id)
{
    new 
topPath[192];
    
GetFile(topPathTOP_15);
    
    
format(topPath191"%s/pro_%s.cfg"topPathmapName);
    
    if(!
file_exists(topPath) )
        return;
    
    static 
szLine[256], szSteam[32], getSteam[32], getTime[14];
    
get_user_authid(idszSteam31);
    
    static 
iLineiLen;
    
    while(
read_file(topPathiLine++, szLine255iLen) )
    {
        
parse(szLinegetTime13getSteam31);
        
        if(
equal(szSteamgetSteam) )
        {
            
fBestTime[id] = str_to_float(getTime);
            
BestTime[id] = floatround(fBestTime[id]);
            return;
        }
    }
    
    
format(topPath191"%s/nub_%s.cfg"topPathmapName);
    
    while(
read_file(topPathiLine++, szLine255iLen) )
    {
        
parse(szLinegetTime13getSteam31);
        
        if(
equal(szSteamgetSteam) )
        {
            
fBestTime[id] = str_to_float(getTime);
            
BestTime[id] = floatround(fBestTime[id]);
            return;
        }
    }
    
    return;

Sry, my english isn't very good.

Thanks
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...

Last edited by Alucard^; 06-03-2010 at 02:04.
Alucard^ is offline
Send a message via Skype™ to Alucard^
 


Thread Tools
Display Modes

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 05:27.


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