Rules FAQ Members List Search Register Login

 Raised This Month: \$231 Target: \$400 57%

Author Message
tepegoz
Senior Member
Join Date: Apr 2019
 04-12-2021 , 11:28   Sort order is mixing sometimes #1 I have this code but sometimes sort order is mixing for public displayasdls(id). Example: Nick1 - 10 Nick2 - 9 Nick3 - 8 Nick4 - 7 Nick5 - 6 But sometime showing this type: Nick5 - 6 Nick4 - 7 Nick1 - 10 Nick3 - 8 Nick2 - 9 can you fix this problem or can you convert this script ? PHP Code: ``` public displayasdls(id){        new teals[1025];        new len = 0, i, x;        new temp_name[64];        new tealrecord[33];        new namerecord[64][64];        tealrecord[0]=0;        for(i=1;i<=maxplayers;i++)        {            if(!is_user_bot(i) &&  !is_user_hltv(i) && is_user_connected(i)){                        tealrecord[i]=MaleRecord[i][TEAL];                get_user_name(i, namerecord[i], 13)            }        }                    for(i=1;i<=maxplayers;i++)            {                if(tealrecord[i]>tealrecord[i-1])                {                    x=tealrecord[i];                    tealrecord[i]=tealrecord[i-1];                    tealrecord[i-1]=x;                    temp_name=namerecord[i];                    namerecord[i]=namerecord[i-1];                    namerecord[i-1]=temp_name;                }        }        len += format(steals[len], 512-len, "TOP TEAL^n^n")        len += format(steals[len], 512-len, "%s  -  %i^n",namerecord[0], tealrecord[0])        len += format(steals[len], 512-len, "%s  -  %i^n",namerecord[1], tealrecord[1])        len += format(steals[len], 512-len, "%s  -  %i^n",namerecord[2], tealrecord[2])        len += format(steals[len], 512-len, "%s  -  %i^n",namerecord[3], tealrecord[3])        len += format(steals[len], 512-len, "%s  -  %i",namerecord[4], tealrecord[4])                set_dhudmessage(0, 255, 0,  0.38, 0.0, 0, 0.2, 3.0, 0.2, 0.1)        show_dhudmessage(id, "%s", teals)}  ``` PHP Code: ``` new MaleRecord[MAX_PLAYER + 1][RECORDS+1]  ``` Last edited by tepegoz; 04-16-2021 at 13:59.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
 04-12-2021 , 17:54   Re: Sort order is mixing sometimes #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 steals[ 1025 ] , len;    new rdData[ MAX_PLAYERS + 1] [ RankData ];    new iPlayers[ 32 ] , iNum , iPlayer , i , szName[ 32 ] , iNumRanked;        get_players( iPlayers , iNum , "ch" );    for ( i = 0 ; i < iNum ; i++ )    {            iPlayer = iPlayers[ i ];                rdData[ i ][ RankID ] = iPlayer;        rdData[ i ][ RankValue ] = MadeRecord[ iPlayer ][ STEAL ];    }        SortCustom2D( _:rdData , iNum , "SortCompare" );        iNumRanked = min( iNum , MaxToRank );    len = copy(steals, charsmax( steals ) , "TOP STEAL^n^n")        for ( i = 0 ; i < iNumRanked ; i++ )     {        get_user_name( rdData[ i ][ RankID ] , szName , charsmax( szName ) );        len += formatex( steals[ len ] , charsmax( steals )-len, "%s  -  %i^n" , szName , rdData[ i ][ RankValue ] )    }        set_dhudmessage(0, 255, 0,  0.38, 0.0, 0, 0.2, 3.0, 0.2, 0.1)    show_dhudmessage(id, steals)}public SortCompare( elem1[] , elem2[] ) {     if ( elem1[ 1 ] > elem2[ 1 ] )         return -1;     else if(elem1[ 1 ] < elem2[ 1 ] )         return 1;     else        return 0; }  ``` __________________ Last edited by Bugsy; 04-12-2021 at 23:44.
tepegoz
Senior Member
Join Date: Apr 2019
 04-13-2021 , 09:30   Re: Sort order is mixing sometimes #3 thank you very much.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 13:53.

 DMCA - Archive - Top