Raised This Month: $ Target: $400
 0% 

ranking system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-17-2011 , 15:16   ranking system
Reply With Quote #1

Hey i made a ranking system for my mod

and yes it works very good

but 1- the ranking system is just for the sql version

how do i add it so it works with vault

2- in the sql ranking system the /top15 shows the top 15 in the chat

i want it in a motd how to do that

here is some codes that you may need:

Code:
public Show_Rank(id)
{
    for(new i; i < g_iMaxPlayers; i++)
    {
        if(is_user_connected(i) && get_cvar_num("SaveXP") == 1  && !is_user_bot(id)) {
           SaveData(i)
        }
    }
        
    new Data[1]
    Data[0] = id
    
    new szTemp[512]
    format(szTemp,charsmax(szTemp),"SELECT COUNT(*) FROM `xpmod` WHERE `xp` >= %d", PlayerXP[id])
    SQL_ThreadQuery(g_SqlTuple,"Sql_Rank",szTemp,Data,1)
        
    return PLUGIN_CONTINUE
}

public Sql_Rank(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
{
    if(FailState == TQUERY_CONNECT_FAILED)
            log_amx("Load - Could not connect to SQL database.  [%d] %s", Errcode, Error)
    else if(FailState == TQUERY_QUERY_FAILED)
            log_amx("Load Query failed. [%d] %s", Errcode, Error)
  
    new count = 0
    count = SQL_ReadResult(Query,0)
    if(count == 0)
    count = 1
    
    new id
    id = Data[0]

    client_print(id, print_chat, "[XP Mod] %L", id, "RANK", count, PlayerLevel[id] , PlayerXP[id])
    
    return PLUGIN_HANDLED
}

public ShowTop15(id)
{
    //i must save stat for will haven't error into top15.
    //
    new Data[1]
    Data[0] = id
    
    // no need for a variable since it's not being formatted
    /*new Temp[512]
    format(Temp,charsmax(Temp),"SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;")
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15",Temp,Data,1)*/
    SQL_ThreadQuery(g_SqlTuple,"Sql_Top15","SELECT steamid, xp FROM xpmod ORDER BY xp DESC LIMIT 15;",Data,1)
    return PLUGIN_CONTINUE;
}

public Sql_Top15(FailState,Handle:hQuery,Error[],Errcode,Data[],DataSize) 
{
    // get player who is looking at top
    new id = Data[ 0 ];
    
    // check for errors
    if( FailState == TQUERY_CONNECT_FAILED
    ||  FailState == TQUERY_QUERY_FAILED )
    {
        log_amx( "Error on top15 query (%i): %s", Errcode, Error );
        console_print( id, "Error on top15 query (%i): %s", Errcode, Error );
        return;
    }
    
    new szSteamID[ 35 ], PlayerXP;
    new iPos = 1;
    
    while( SQL_MoreResults( hQuery ) )
    {
        SQL_ReadResult( hQuery, 0, szSteamID, charsmax( szSteamID ) );
        PlayerXP = SQL_ReadResult( hQuery, 1 );

        client_print(id,print_chat, "[XP Mod] %L", id, "RANK2", iPos, szSteamID, PlayerXP);
        
        iPos++;
        SQL_NextRow( hQuery );
    }
}
3. Can anyone show a tut how to make ranking system with sqlx that works better that this and thx
and thanks.
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.




Last edited by modernwarfare; 09-18-2011 at 10:15.
modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-17-2011 , 15:21   Re: ranking system
Reply With Quote #2

Try this one.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-17-2011 , 15:32   Re: ranking system
Reply With Quote #3

Quote:
Originally Posted by Evaldas.Grigas View Post
Try this one.

you didnt even read the main post!
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.



modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 09-17-2011 , 15:36   Re: ranking system
Reply With Quote #4

Take some code from plugin I posted (ask credits first), write in the credits his name and whoalia your done.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
HBxander
Senior Member
Join Date: Jan 2011
Location: Behind you!
Old 09-17-2011 , 16:16   Re: ranking system
Reply With Quote #5

I wont make the code for u, but i have some code i am using for a nVault top10 in motd.

I am using nvault_util, so u'll have to use that too. I send u the related stuff to it, in a single post, and the code in a post alone.
Here we go:

PHP Code:
const TOPRANKS 10
new iTopMoney TOPRANKS ]
new 
TopNames TOPRANKS 
change iTopMoney to the value u want to remember. In this case, its taking it as Money.
Edit 'TOPRANKS' to 15, if you really want it to a top15 ( imo. top10 is better, and more smooth. )

PHP Code:
CreateTopTen ( ) 
Put this in your plugin_init ( ) case.

PHP Code:
new szName 32 ], szNameTemp 32 ]
    
get_user_name iPlayerszNamecharsmax szName ) )
    
formatex szNameTempcharsmax szNameTemp ), "%s"szName )
    
    
nvault_set gVaultNamesszAuthszNameTemp 
Put this in your Save case.

PHP Code:
public CreateTopTen ( )
{
    new Array:
aNames, Array:aAuths, Array:aMoney
    
new iTotal SortTopPlayers aNamesaAuthsaMoney )
    
    new 
szName 156 ], szAuth 156 ]
    
    for ( new 
0TOPRANKSi++ )
    {
        if ( 
iTotal )
        {
            
ArrayGetString aNamesiszNamecharsmax szName ) )
            
ArrayGetString aAuthsiszAuthcharsmax szAuth ) )
            
replace_all szNamecharsmax szName ), "&""&amp;" )
            
replace_all szNamecharsmax szName ), "<""&lt;" )
            
replace_all szNamecharsmax szName ), ">""&gt;" )
            
formatex TopNames ], charsmax TopNames [ ] ), "%s"szName )
            
iTopMoney ] = ArrayGetCell aMoney)
        }
    }
    
    
ArrayDestroy aNames )
    
ArrayDestroy aAuths )
    
ArrayDestroy aMoney )
    
    return 
PLUGIN_HANDLED
}

public 
CmdTopShow iPlayer )
{
    new 
html_motd 2500 ], len
    
    len 
formatex html_motd len ], charsmax html_motd ) - len"<STYLE>body{background:#252525;color:#ofcbc2;font-family:sand-serif}table{width:100%%;font-size:16px}</STYLE><table cellpadding=2 cellspacing=0 border=0>" )
    
len += formatex html_motd len ], charsmax html_motd ) - len"<tr align=center bgcolor=%52697B><th width=14%% align=left><font color=white> Rank: <th width=10%%> Name: <th width=10%%> Total Points:" )
    
    for ( new 
=0TOPRANKSi++ )
    {
        if ( 
== || == || == || == || == )
        {
            
len += formatex  html_motd len ], charsmax html_motd ) - len"<tr align=center%s><td align=left><font color=white> %i. <td> %s <td> %i"" bgcolor=#252525", ( ), TopNames ], iTopMoney ] )
        }
        else
        {
            
len += formatex  html_motd len ], charsmax html_motd ) - len"<tr align=center%s><td align=left><font color=white> %i. <td> %s <td> %i"" bgcolor=#4F4F4F", ( ), TopNames ], iTopMoney ] )
        }
    }
    
    
len += formatex html_motd len ], charsmax html_motd ) - len"</table></body>" )
    
    
show_motd iPlayerhtml_motd"#MM | Top10" )
    
    return 
PLUGIN_HANDLED
}

SortTopPlayers ( &Array:aNames, &Array:aSteamIDs, &Array:aMoney )
{
    
aNames ArrayCreate 32 )
    
aSteamIDs ArrayCreate 35 )
    
aMoney ArrayCreate )
    
    new 
hVault nvault_util_open "HNSMoneyMod" )
    new 
iCount nvault_util_count hVault )
    new 
iPos
    
new szSteamID 35 ], szMoney 11 ], iTimeStampszName 32 ]
    
    for ( new 
0iCounti++ )
    {
        
iPos nvault_util_read hVaultiPosszSteamIDcharsmax szSteamID ), szMoneycharsmax szMoney ), iTimeStamp )
        
        
nvault_get gVaultNamesszSteamIDszNamecharsmax szName ) )
        
        
ArrayPushString aNamesszName )
        
ArrayPushString aSteamIDsszSteamID )
        
ArrayPushCell aMoneystr_to_num szMoney ) )
    }
    
nvault_util_close hVault )
    
    new 
iMoney
    
for ( new 0j< ( iCount ); i++ )
    {
        
iMoney ArrayGetCell aMoney)
        
        for ( 
1iCountj++ )
        {
            if ( 
iMoney ArrayGetCell aMoney) )
            {
                
ArraySwap aNamesi)
                
ArraySwap aSteamIDsi)
                
ArraySwap aMoneyi)
                
                
i--
                break
            }
        }
    }
    return 
iCount

This is the real code, wich makes the top10.

EDIT: I've made the code myself, so its connected with my MoneyMod. You'll have to either, rewrite the code, or just figure out the stuff i've made, so its connected to your mod.
Since im not using the code anymore, i wouldn't bother you to pay for it.
__________________
Selling:

- PointMod for Hide And Seek - $20
- Private BlockMaker with Weapon Block And More - $50
- Achievements ( FFA GamePlay ) - $25

PM Me about Private Work!

Last edited by HBxander; 09-17-2011 at 16:18.
HBxander is offline
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-17-2011 , 17:31   Re: ranking system
Reply With Quote #6

Quote:
Originally Posted by Evaldas.Grigas View Post
Take some code from plugin I posted (ask credits first), write in the credits his name and whoalia your done.

ok i will take a look

Quote:
Originally Posted by HBxander View Post
I wont make the code for u, but i have some code i am using for a nVault top10 in motd.

I am using nvault_util, so u'll have to use that too. I send u the related stuff to it, in a single post, and the code in a post alone.
Here we go:

PHP Code:
const TOPRANKS 10
new iTopMoney TOPRANKS ]
new 
TopNames TOPRANKS 
change iTopMoney to the value u want to remember. In this case, its taking it as Money.
Edit 'TOPRANKS' to 15, if you really want it to a top15 ( imo. top10 is better, and more smooth. )

PHP Code:
CreateTopTen ( ) 
Put this in your plugin_init ( ) case.

PHP Code:
new szName 32 ], szNameTemp 32 ]
    
get_user_name iPlayerszNamecharsmax szName ) )
    
formatex szNameTempcharsmax szNameTemp ), "%s"szName )
    
    
nvault_set gVaultNamesszAuthszNameTemp 
Put this in your Save case.

PHP Code:
public CreateTopTen ( )
{
    new Array:
aNames, Array:aAuths, Array:aMoney
    
new iTotal SortTopPlayers aNamesaAuthsaMoney )
    
    new 
szName 156 ], szAuth 156 ]
    
    for ( new 
0TOPRANKSi++ )
    {
        if ( 
iTotal )
        {
            
ArrayGetString aNamesiszNamecharsmax szName ) )
            
ArrayGetString aAuthsiszAuthcharsmax szAuth ) )
            
replace_all szNamecharsmax szName ), "&""&amp;" )
            
replace_all szNamecharsmax szName ), "<""&lt;" )
            
replace_all szNamecharsmax szName ), ">""&gt;" )
            
formatex TopNames ], charsmax TopNames [ ] ), "%s"szName )
            
iTopMoney ] = ArrayGetCell aMoney)
        }
    }
    
    
ArrayDestroy aNames )
    
ArrayDestroy aAuths )
    
ArrayDestroy aMoney )
    
    return 
PLUGIN_HANDLED
}

public 
CmdTopShow iPlayer )
{
    new 
html_motd 2500 ], len
    
    len 
formatex html_motd len ], charsmax html_motd ) - len"<STYLE>body{background:#252525;color:#ofcbc2;font-family:sand-serif}table{width:100%%;font-size:16px}</STYLE><table cellpadding=2 cellspacing=0 border=0>" )
    
len += formatex html_motd len ], charsmax html_motd ) - len"<tr align=center bgcolor=%52697B><th width=14%% align=left><font color=white> Rank: <th width=10%%> Name: <th width=10%%> Total Points:" )
    
    for ( new 
=0TOPRANKSi++ )
    {
        if ( 
== || == || == || == || == )
        {
            
len += formatex  html_motd len ], charsmax html_motd ) - len"<tr align=center%s><td align=left><font color=white> %i. <td> %s <td> %i"" bgcolor=#252525", ( ), TopNames ], iTopMoney ] )
        }
        else
        {
            
len += formatex  html_motd len ], charsmax html_motd ) - len"<tr align=center%s><td align=left><font color=white> %i. <td> %s <td> %i"" bgcolor=#4F4F4F", ( ), TopNames ], iTopMoney ] )
        }
    }
    
    
len += formatex html_motd len ], charsmax html_motd ) - len"</table></body>" )
    
    
show_motd iPlayerhtml_motd"#MM | Top10" )
    
    return 
PLUGIN_HANDLED
}

SortTopPlayers ( &Array:aNames, &Array:aSteamIDs, &Array:aMoney )
{
    
aNames ArrayCreate 32 )
    
aSteamIDs ArrayCreate 35 )
    
aMoney ArrayCreate )
    
    new 
hVault nvault_util_open "HNSMoneyMod" )
    new 
iCount nvault_util_count hVault )
    new 
iPos
    
new szSteamID 35 ], szMoney 11 ], iTimeStampszName 32 ]
    
    for ( new 
0iCounti++ )
    {
        
iPos nvault_util_read hVaultiPosszSteamIDcharsmax szSteamID ), szMoneycharsmax szMoney ), iTimeStamp )
        
        
nvault_get gVaultNamesszSteamIDszNamecharsmax szName ) )
        
        
ArrayPushString aNamesszName )
        
ArrayPushString aSteamIDsszSteamID )
        
ArrayPushCell aMoneystr_to_num szMoney ) )
    }
    
nvault_util_close hVault )
    
    new 
iMoney
    
for ( new 0j< ( iCount ); i++ )
    {
        
iMoney ArrayGetCell aMoney)
        
        for ( 
1iCountj++ )
        {
            if ( 
iMoney ArrayGetCell aMoney) )
            {
                
ArraySwap aNamesi)
                
ArraySwap aSteamIDsi)
                
ArraySwap aMoneyi)
                
                
i--
                break
            }
        }
    }
    return 
iCount

This is the real code, wich makes the top10.

EDIT: I've made the code myself, so its connected with my MoneyMod. You'll have to either, rewrite the code, or just figure out the stuff i've made, so its connected to your mod.
Since im not using the code anymore, i wouldn't bother you to pay for it.

thx for that , i will wait maybe someone else know how to make it with vault
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.



modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-18-2011 , 10:15   Re: ranking system
Reply With Quote #7

updated main post
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.



modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 09-22-2011 , 02:44   Re: ranking system
Reply With Quote #8

.........
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
Old 09-22-2011, 04:02
dingtonucretia
This message has been deleted by asherkin. Reason: Spam.
modernwarfare
Senior Member
Join Date: Aug 2011
Location: sweden
Old 09-22-2011 , 09:49   Re: ranking system
Reply With Quote #9

Quote:
Originally Posted by JoKeR LauGh View Post
.........

you are not allowed to write something random like that????
__________________
Im supporting/coding XP Mod Plugin
Free Palestine
R.I.P. The 2967 American people that lost their lives 9/11 and R.I.P.
The 48,644 Afghan and 1,690,903 Iraqi people that paid the ultimate price for a crime they did not commit.



modernwarfare is offline
Send a message via MSN to modernwarfare Send a message via Skype™ to modernwarfare
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 09-22-2011 , 09:53   Re: ranking system
Reply With Quote #10

Quote:
Originally Posted by modernwarfare View Post
you are not allowed to write something random like that????
wtf with you?
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh 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:57.


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