Raised This Month: $203 Target: $400
 50% 

Retrieving data from vault


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-26-2015 , 08:17   Retrieving data from vault
Reply With Quote #1

So I have a vault that stores a name and a number. How could I get all the key-data combinations and display them in console, aligned, like below?
Code:
Name | Num
Name2 | Num2
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-26-2015 , 08:37   Re: Retrieving data from vault
Reply With Quote #2

Search for nvault utility include
__________________
Bugsy is offline
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-30-2015 , 03:13   Re: Retrieving data from vault
Reply With Quote #3

Quote:
Originally Posted by Bugsy View Post
Search for nvault utility include
Thanks, but as I'm not so familiar with nvault, that didn't help me. I tried some things, but I can't get it done. Could you please be more explicit? Also, how could I sort them as mentioned?
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-30-2015 , 08:50   Re: Retrieving data from vault
Reply With Quote #4

This is not very efficient. I highly recommend using SQL when any type of sorting is needed or a large amount of data is being stored.
PHP Code:
#include <amxmodx>
#include <nvault_util>

//If you increase MAX_ENTRIES and get a stack error, un-comment the below line.
//#pragma dynamic 32768 

new const Version[] = "0.1";

const 
MAX_ENTRIES 1000;
new const 
VAULT_NAME[] = "original_names";

enum _:VaultSortInfo
{
    
EntryPos,
    
EntryVal
}

public 
plugin_init() 
{
    
register_plugin"nVault Util Sort Example" Version "Bugsy" );
    
    
SortVault();
}

SortVault()
{
    new 
iVault iCount iPos iTimestamp VaultDataMAX_ENTRIES ][ VaultSortInfo ] , szTmp10 ] , szKey255 ];
    
    if ( ( 
iVault nvault_util_openVAULT_NAME ) ) )
    {
        
iCount nvault_util_countiVault );
        
        for ( new 
iCount i++ )
        {
            
VaultData][ EntryPos ] = iPos;
            
iPos nvault_util_readiVault iPos "" szTmp charsmaxszTmp ) , iTimestamp );
            
VaultData][ EntryVal ] = str_to_numszTmp );
        }
    
        
SortCustom2DVaultData iCount ,"stats_custom_compare" );
    
        for ( new 
iCount i++ )
        {
            
nvault_util_readiVault VaultData][ EntryPos ] , szKey charsmaxszKey ) , "" iTimestamp );
            
server_print"[%d] %s | %d" szKey VaultData][ EntryVal ] );
        }
        
        
nvault_util_closeiVault );
    }
}

public 
stats_custom_compare(elem1[],elem2[])
{
    if(
elem1[1] > elem2[1]) 
        return 
1;
    else if(
elem1[1] < elem2[1]) 
        return -
1;
        
    return 
0;

__________________
Bugsy is offline
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 06-07-2015 , 06:09   Re: Retrieving data from vault
Reply With Quote #5

Alright, thank you very much!
__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Reply


Thread Tools
Display Modes

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 12:15.


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