Raised This Month: $ Target: $400
 0% 

get all entries [top15]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 04-12-2013 , 10:02   Re: get all entries [top15]
Reply With Quote #1

You have it quite mixed up.

Try it like this:

Code:
#include <amxmodx> #include <nvault_util> new g_iVaultHandle, g_iFileHandle; enum _:PlayersData {     PLAYER_NAME[ 32 ],     PLAYER_RANK, } new Array:g_PlayersArray; public plugin_init() {     g_PlayersArray = ArrayCreate( PlayersData );             /*  I put this next line in to remind you that g_iFileHandle is actually a             file handle ( hence its name ) not an nVault handle, therefore it             cannot be used in conjunction with the nVault functions                                                 */         g_iVaultHandle = nvault_open( "yourvault" );         g_iFileHandle = nvault_util_open( "yourvault" );         nvault_util_readall( g_iFileHandle, "On_nVaultUtil_ReadEntry" );         ArraySort( g_PlayersArray, "ArrayItem_Compare" );         register_clcmd( "say /ranks", "ClientCommand_ShowMotd" ); } public On_nVaultUtil_ReadEntry( i, iTotal, const szKey[], const szData[]/*, iTimeStamp, const Data[], iSize*/ ) {     static ArrayData[ PlayersData ], szRank[ 4 ];             /*  Save name with quotes so it can be parsed   */             parse( szData, szRank, charsmax( szRank ), ArrayData[ PLAYER_NAME ], charsmax( ArrayData[ PLAYER_NAME ] ) );         remove_quotes( ArrayData[ PLAYER_NAME ] );     ArrayData[ PLAYER_RANK ] = str_to_num( szRank );     ArrayPushArray( g_PlayersArray, ArrayData ); } public ArrayItem_Compare( Array:array, iItem1, iItem2/*, const szData[], iSize*/ ) {     static ArrayData1[ PlayersData ], ArrayData2[ PlayersData ];         ArrayGetArray( g_PlayersArray, iItem1, ArrayData1 );     ArrayGetArray( g_PlayersArray, iItem2, ArrayData2 );             return clamp( ArrayData2[ PLAYER_RANK ] - ArrayData1[ PLAYER_RANK ], -1, 1 ); } public ClientCommand_ShowMotd( id ) {     new iSize = ArraySize( g_PlayersArray );            new ArrayData[ PlayersData ];                                                     for( new i ; i < iSize ; i ++ )     {         ArrayGetArray( g_PlayersArray, i, ArrayData );                     /*  Add your player into MOTD string here. int i in each iteration                 will hold the index of the entry with the next player in order by                 rank.                             ArrayData[ PLAYER_NAME ] - Is the string holding player's name                 ArrayData[ PLAYER_RANK ] - Is the int holding player's rank                                                 */     }         //show_motd( id, .... ); }
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet 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 10:47.


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