Raised This Month: $ Target: $400
 0% 

bubble sort


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-08-2009 , 00:42   Re: bubble sort
Reply With Quote #2

You will need to do the MOTD work on your own. This will print the topX in server console just for demonstration.
PHP Code:
//Declare array to store player frags for sorting
new g_PlayerFrags33 ][ ];

//Assign player data to array
g_PlayerFragsid ][ ] = id;
g_PlayerFragsid ][ ] = get_user_fragsid );

//Display
public DisplayInfo()
{
    new 
iPlayer szName33 ];

    
//Sort frags
    
SortCustom2Dg_PlayerFrags 33 "fn_StatsCompare" );

    
//If you want only top 3 use "i < 3" instead of "i < sizeof g_PlayerFrags"
    
for ( new sizeof g_PlayerFrags i++ )
    {
        
iPlayer g_PlayerFrags][ ];
    
        if ( 
is_user_connectediPlayer ) )
        {
            
get_user_nameiPlayer szName 32 );
            
server_print"Name: %s - Rank: %d - Frags: %d" szName i+1g_PlayerFrags][ ] );
        }
    }
}

public 
fn_StatsCompareelem1[] , elem2[] )
{
    if( 
elem1[1] > elem2[1] ) 
        return -
1;
    else if( 
elem1[1] < elem2[1] )
        return 
1;
    
    return 
0;

__________________

Last edited by Bugsy; 08-08-2009 at 01:21.
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 18:28.


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