Raised This Month: $ Target: $400
 0% 

How can i read all data in a fvault file?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Enum
Junior Member
Join Date: Oct 2010
Location: ee.uu
Old 10-16-2010 , 14:29   How can i read all data in a fvault file?
Reply With Quote #1

example i have this data in my fvault file:

"Name" "1 2"

and my questions is:
How can i make a for and obtain all data? i tried this, but doesn't work ;(

PHP Code:
static Data[512], Name[33], Num1[11], Num2[11];

for( new 
1<= 20i++ )
{
     
get_user_nameiName32 )

     if( 
fvault_get_dataDataBaseNameData511 ) )
     {
          
parseDataNum110Num210 )

          
client_printidprint_console"Names: %s"Name )
          
client_printidprint_console"Nums: %i-%i"str_to_numNum1 ), str_to_numNum2 ) )
     }
     else
     {
          
client_printidprint_console"No data" )
          break;
     }

PD: And in the for, how can i obtain automatically the size of all data? example i push 20, but if is more? Thanks.

Excuse my little english
Enum is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-16-2010 , 15:33   Re: How can i read all data in a fvault file?
Reply With Quote #2

I don't know about fvault specifically but get_user_name(i, Name, 32) will give you errors.
__________________
fysiks is offline
Enum
Junior Member
Join Date: Oct 2010
Location: ee.uu
Old 10-17-2010 , 13:21   Re: How can i read all data in a fvault file?
Reply With Quote #3

and of nvault you know?
y tried that...

PHP Code:
        for( new 1<= MAX_ADMINSi++ )
        {
            
// format( Vaultkey, 63, "Enum" )
            
if(nvault_lookup(DataBaseVaultkeyVaultdata1500Timestamp))
            {    
                   
parseVaultkeyPlayerName32 )
                
                   if(
containi PlayerName"<" ) != -)
                        
replacePlayerName32"<""" )
                
                   
parseVaultdataNum110Num210,  )
                   
client_printidprint_console"Names: %s"PlayerName )
                   
client_printidprint_console"Nums: %i-%i"str_to_numNum1 ), str_to_numNum2 ) )
            }
            else
            {
                   
client_printidprint_console"No data" )
                   break;
            }
        } 
But i need obtain all names in nvault_lookup, but i don't know how can i make this...

i desperate...
if you can help me, i really appreciate it.

Thanks and excuse my english again.
Enum is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2010 , 14:49   Re: How can i read all data in a fvault file?
Reply With Quote #4

How are they formatted in the nvault data?

"name1,name2,name3,name4"? Are they all stored in the same key with the key being the players name, in your case "Enum"? Give an example key/data that you are trying to manipulate and what you wish the end result to be.
__________________
Bugsy is offline
Enum
Junior Member
Join Date: Oct 2010
Location: ee.uu
Old 10-17-2010 , 15:59   Re: How can i read all data in a fvault file?
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
How are they formatted in the nvault data?

"name1,name2,name3,name4"? Are they all stored in the same key with the key being the players name, in your case "Enum"? Give an example key/data that you are trying to manipulate and what you wish the end result to be.
Ok, here go.

I have this in my nvault file.

"Test1" "100 200"
"Test2" "200 300"
"Test3" "500 1200"
"Test4" "6000 10000"


Ok, with a for, i want read the nvault file and in a print say all names ( Test1, Test2, Test3, Test4 ) And all data.

Example:

PHP Code:
for( new 0<= 10i++ ) // i want the number exactly of data saved, not 10
{
     
// get all names and all data in the nvault file

    // make a print with the names and the data in the names.


Result:

PHP Code:
client_printidprint_console"Names: Test1 - Test2 - Test3 - Test4. - Values: 100 200 - 200 300 - 500 1200 - 6000 10000."
if you not understand me, question me
Enum is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2010 , 16:48   Re: How can i read all data in a fvault file?
Reply With Quote #6

You will need to use nvault utility for this. I posted 2 methods, one allows you to have a for loop to iterate through all or you can use the readall method where everything is done for you.

nvault_util

PHP Code:
#include <amxmodx>
#include <nvault_util>

new g_szKeys512 ] , g_iKeyPos;
new 
g_szValues512 ] , g_iValPos;
new 
g_iVault;

public 
plugin_init()
{
    
g_iVault nvault_util_open"YourVaultFile" );
    
    
UsingLoop();
    
//UsingForward();
    
    
new iNumSaved nvault_util_countg_iVault );
    
    
server_print"Total items=%d" iNumSaved )
    
server_printg_szKeys );
    
server_printg_szValues );
    
    
nvault_util_closeg_iVault );
}

public 
UsingForward() 
{
    
g_iKeyPos 0;
    
g_iValPos 0;

    
nvault_util_readallg_iVault "fw_Nvault_ReadAll" );
}

public 
UsingLoop()
{
    new 
iPos iNumSaved nvault_util_countg_iVault );
    new 
szKey32 ] , szVal10 ] , iTS;
    
    
g_iKeyPos 0;
    
g_iValPos 0;

    for ( new 
iNumSaved i++ )
    {
        
iPos nvault_util_readg_iVault iPos szKey charsmaxszKey ) , szVal charsmaxszVal ) , iTS );
    
        
g_iKeyPos += formatexg_szKeysg_iKeyPos ] , charsmaxg_szKeys ) - g_iKeyPos "%s - " szKey );
        
g_iValPos += formatexg_szValuesg_iValPos ] , charsmaxg_szValues ) - g_iValPos "%s - " szVal );
    }
}

public 
fw_Nvault_ReadAlliCurrent iTotal , const szKey[] , const szVal[] , iTimeStamp )
{
    
g_iKeyPos += formatexg_szKeysg_iKeyPos ] , charsmaxg_szKeys ) - g_iKeyPos "%s - " szKey );
    
g_iValPos += formatexg_szValuesg_iValPos ] , charsmaxg_szValues ) - g_iValPos "%s - " szVal );

__________________

Last edited by Bugsy; 10-17-2010 at 17:00.
Bugsy is offline
Enum
Junior Member
Join Date: Oct 2010
Location: ee.uu
Old 10-17-2010 , 21:06   Re: How can i read all data in a fvault file?
Reply With Quote #7

Thanks, that works fine only for somethig.
I have this in my nvault file

"Enum 15 15 15 15 15".

and in console appears two 15 less, why?

Result:

Names: Enum
Values: 15 15 15

Thanks so much bugsy ;)
Enum is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-17-2010 , 23:39   Re: How can i read all data in a fvault file?
Reply With Quote #8

how big is your dest string? Show code
__________________
Bugsy is offline
Enum
Junior Member
Join Date: Oct 2010
Location: ee.uu
Old 10-18-2010 , 11:12   Re: How can i read all data in a fvault file?
Reply With Quote #9

Quote:
Originally Posted by Bugsy View Post
how big is your dest string? Show code
I tried with UsingForwards and works fine, thanks!

A last question

If i wanna print this:

client_print( id, print_chat, "Name: %s - 15/15/15 at 15:15" )


how can i make this? Thanks.

Last edited by Enum; 10-18-2010 at 11:19.
Enum is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-18-2010 , 12:56   Re: How can i read all data in a fvault file?
Reply With Quote #10

Code:
client_print( id, print_chat, "Name: %s - %d/%d/%d at %d:%d", name, num1, num2, num3, num4, num5)
__________________
fysiks 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:25.


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