AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get ranks in ascending order (https://forums.alliedmods.net/showthread.php?t=194110)

Re4per 08-25-2012 10:51

Get ranks in ascending order
 
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.

Napoleon_be 08-25-2012 12:40

Re: Get ranks in ascending order
 
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.

Re4per 08-25-2012 15:25

Re: Get ranks in ascending order
 
How exactly does this work?

Liverwiz 08-25-2012 17:30

Re: Get ranks in ascending order
 
Use the sorting natives provided by amxmodx.
SortIntegers()
http://www.amxmodx.org/funcwiki.php?go=inc&id=52

Re4per 08-25-2012 17:44

Re: Get ranks in ascending order
 
Thanks!


All times are GMT -4. The time now is 05:51.

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