Raised This Month: $ Target: $400
 0% 

Get ranks in ascending order


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Re4per
Junior Member
Join Date: Aug 2012
Old 08-25-2012 , 10:51   Get ranks in ascending order
Reply With Quote #1

For example, i have 10 players in my server and i want to get their rankings in ascending order, like current top 10. P.S My ranking system is in the same plugin.

Rank[?] = 1
Rank[?] = 2
Rank[?] = 3

etc.

Last edited by Re4per; 08-25-2012 at 11:19.
Re4per is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 08-25-2012 , 12:40   Re: Get ranks in ascending order
Reply With Quote #2

PHP Code:
#include <amxmodx>

#define VERSION "1.0"

new xp[33], level[33]

public 
plugin_init() {    
    
register_plugin("Rank System"VERSION"NapoleoN#")

    
    
FunctionName(1)
}

stock FunctionName( const type ) {
    
    new 
iPlayer
    
for(new 1<= 32i++)
        if(
is_user_connected(i))
        if( !
iPlayer 
    
|| ( (type && (level[iPlayer] < level[i]) || (!type && (level[iPlayer] > level[i]) ) )
    || ( (
level[iPlayer] == level[i]) && ( (type && xp[iPlayer] < xp[i]) || (!type && xp[iPlayer] > xp[i]) )) ) )
    
iPlayer i
    
return iPlayer

Not sure if this will work.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Re4per
Junior Member
Join Date: Aug 2012
Old 08-25-2012 , 15:25   Re: Get ranks in ascending order
Reply With Quote #3

How exactly does this work?
Re4per is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 08-25-2012 , 17:30   Re: Get ranks in ascending order
Reply With Quote #4

Use the sorting natives provided by amxmodx.
SortIntegers()
http://www.amxmodx.org/funcwiki.php?go=inc&id=52
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 08-25-2012 at 17:30.
Liverwiz is offline
Re4per
Junior Member
Join Date: Aug 2012
Old 08-25-2012 , 17:44   Re: Get ranks in ascending order
Reply With Quote #5

Thanks!
Re4per 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 05:51.


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