Raised This Month: $ Target: $400
 0% 

bubble sort


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-09-2009 , 17:39   Re: bubble sort
Reply With Quote #11

This could be made more efficiently but it works.

PHP Code:
#include <amxmodx>

#define PLUGIN     "Frag Rank HUD"
#define VERSION    "1.0"
#define AUTHOR     "bugsy"

new g_PlayerFrags33 ][ ];

enum _:Team
{
    
CS_TERRORIST 1,
    
CS_CT
};

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event"ScoreInfo" "fw_EvScoreInfo" "a" );
    
    
set_task0.5 "DisplayHUD" ___"b" );
}

public 
client_disconnectid )
{
    
g_PlayerFragsid ][ ] = 0;
    
g_PlayerFragsid ][ ] = 0;
}

public 
fw_EvScoreInfo()
{
    static 
idid read_data);
    
g_PlayerFragsid ][ ] = id;
    
g_PlayerFragsid ][ ] = read_data);
}

public 
DisplayHUDid )
{
    static 
iPlayers32 ] , iNum;
    static 
iPlayer iFrags iTeam szName33 ];
    static 
iPlayerFrags33 ][ ];
    static 
sz_T_HUD512 ] , i_T_Pos;
    static 
sz_CT_HUD512 ] , i_CT_Pos;
    static 
i_T_Rank i_CT_Rank;
    
    
iPlayerFrags g_PlayerFrags;
    
    
SortCustom2DiPlayerFrags 33 "fn_StatsCompare" );

    
i_T_Pos 0;
    
i_CT_Pos 0;
    
i_T_Rank 0;
    
i_CT_Rank 0;
    
    for ( new 
sizeofg_PlayerFrags ) ; i++ )
    {
        
iPlayer iPlayerFrags][ ];
        
iFrags iPlayerFrags][ ];
        
iTeam get_user_teamiPlayer );
        
        if ( 
is_user_connectediPlayer ) && iFrags )
        {
            
get_user_nameiPlayer szName 32 );
            
            if ( 
iTeam == CS_TERRORIST )
            {
                if ( !
i_T_Pos )
                    
i_T_Pos formatexsz_T_HUDi_T_Pos ] , 512-i_T_Pos "Terrorist Ranks^n^n" );
                    
                
i_T_Pos += formatexsz_T_HUDi_T_Pos ] , 512-i_T_Pos "%s - Rank: %d - Frags: %d^n" szName , ++i_T_Rank iFrags );
            }
            else if ( 
iTeam == CS_CT )
            {
                if ( !
i_CT_Pos )
                    
i_CT_Pos formatexsz_CT_HUDi_CT_Pos ] , 512-i_CT_Pos "Counter-Terrorist Ranks^n^n" );
                
                
i_CT_Pos += formatexsz_CT_HUDi_CT_Pos ] , 512-i_CT_Pos "%s - Rank: %d - Frags: %d^n" szName , ++i_CT_Rank iFrags );
            }
        }
    }
    
    
set_hudmessage85 255 0.05 0.15 0.0 1.0 )
    
    if ( 
i_T_Pos )
    {
        
sz_T_HUDi_T_Pos ] = 0;
        
        
get_playersiPlayers iNum "e" "TERRORIST" );
        
        if ( 
iNum )
            for ( new 
iNum i++ )
                
show_hudmessageiPlayers] , sz_T_HUD );
    }
    
    if ( 
i_CT_Pos )
    {
        
sz_CT_HUDi_CT_Pos ] = 0;
        
        
get_playersiPlayers iNum "e" "CT" );
        
        if ( 
iNum )
            for ( new 
iNum i++ )
                
show_hudmessageiPlayers] , sz_CT_HUD );
    }
}

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-09-2009 at 17:57.
Bugsy is offline
Reply



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