Raised This Month: $ Target: $400
 0% 

Solved Sort order is mixing sometimes


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-12-2021 , 17:54   Re: Sort order is mixing sometimes
Reply With Quote #2

Your sort logic is bad, I would use SortCustom2D(). Untested and might need some tweaks.

PHP Code:
public displayasdls(id)
{
    
enum _:RankData
    
{
        
RankID,
        
RankValue
    
}
    
    const 
MaxToRank 5;
    
    new 
steals1025 ] , len;
    new 
rdDataMAX_PLAYERS 1] [ RankData ];
    new 
iPlayers32 ] , iNum iPlayer szName32 ] , iNumRanked;
    
    
get_playersiPlayers iNum "ch" );
    for ( 
iNum i++ )
    {    
        
iPlayer iPlayers];
        
        
rdData][ RankID ] = iPlayer;
        
rdData][ RankValue ] = MadeRecordiPlayer ][ STEAL ];
    }
    
    
SortCustom2D_:rdData iNum "SortCompare" );
    
    
iNumRanked miniNum MaxToRank );

    
len copy(stealscharsmaxsteals ) , "TOP STEAL^n^n")
    
    for ( 
iNumRanked i++ ) 
    {
        
get_user_namerdData][ RankID ] , szName charsmaxszName ) );
        
len += formatexstealslen ] , charsmaxsteals )-len"%s  -  %i^n" szName rdData][ RankValue ] )
    }
    
    
set_dhudmessage(02550,  0.380.000.23.00.20.1)
    
show_dhudmessage(idsteals)
}

public 
SortCompareelem1[] , elem2[] ) 

    if ( 
elem1] > elem2] ) 
        return -
1
    else if(
elem1] < elem2] ) 
        return 
1
    else
        return 
0

__________________

Last edited by Bugsy; 04-12-2021 at 23:44.
Bugsy 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 19:55.


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