Raised This Month: $ Target: $400
 0% 

Get two biggest of a series of numbers


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-15-2010 , 17:20   Get two biggest of a series of numbers
Reply With Quote #1

I have an array:

Code:
new playersXP[SH_MAXSLOTS]
I have stored everyones XP inside that array. Is there a way to get the biggest two numbers out of it, and then divide the players who has that XP into separate teams?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-15-2010 , 17:28   Re: Get two biggest of a series of numbers
Reply With Quote #2

Code:
enum _:SortData {     iOriginalIndex,     iValue }; new playersXP[ SH_MAXSLOTS ]; foo( ) {     new eSortData[ SH_MAXSLOTS ][ SortData ];     for( new i = 0; i < SH_MAXSLOTS; i++ )     {         eSortData[ i ][ iOriginalIndex ] = i;         eSortData[ i ][ iValue ] = playersXP[ i ];     }         SortCustom2D( eSortData, SH_MAXSLOTS, "SortData" );         // get top player     new iPlayer1 = eSortData[ 0 ][ iOriginalIndex ];     // get 2nd top player     new iPlayer2 = eSortData[ 1 ][ iOriginalIndex ];     // etc. } public SortData( iElem1[ ], iElem2[ ], iArray[ ], iData[ ], iDataSize ) {     if( iElem1[ iValue ] > iElemt2[ iValue ] ) return -1;     return 1; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 11-15-2010 , 20:22   Re: Get two biggest of a series of numbers
Reply With Quote #3

Thanks, I will try that!
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 11-15-2010 , 20:39   Re: Get two biggest of a series of numbers
Reply With Quote #4

@Exolent: Where did the SortCustom2D( ) come from? Is it a stock?

EDIT: I hate that face, it's supposed to look scared but it looks like interested in a creepy way.
__________________
Hi.
Kreation is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-15-2010 , 21:21   Re: Get two biggest of a series of numbers
Reply With Quote #5

Quote:
Originally Posted by Kreation View Post
@Exolent: Where did the SortCustom2D( ) come from? Is it a stock?

EDIT: I hate that face, it's supposed to look scared but it looks like interested in a creepy way.
It's a native. See sorting.inc.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 11-15-2010 , 21:22   Re: Get two biggest of a series of numbers
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
It's a native. See sorting.inc.
Will do.
__________________
Hi.
Kreation 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 11:23.


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