AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How can i read all data in a fvault file? (https://forums.alliedmods.net/showthread.php?t=140791)

Enum 10-16-2010 14:29

How can i read all data in a fvault file?
 
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 :cry:

fysiks 10-16-2010 15:33

Re: How can i read all data in a fvault file?
 
I don't know about fvault specifically but get_user_name(i, Name, 32) will give you errors.

Enum 10-17-2010 13:21

Re: How can i read all data in a fvault file?
 
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...:cry:

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

Thanks and excuse my english again.

Bugsy 10-17-2010 14:49

Re: How can i read all data in a fvault file?
 
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.

Enum 10-17-2010 15:59

Re: How can i read all data in a fvault file?
 
Quote:

Originally Posted by Bugsy (Post 1327704)
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 :)

Bugsy 10-17-2010 16:48

Re: How can i read all data in a fvault file?
 
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 );



Enum 10-17-2010 21:06

Re: How can i read all data in a fvault file?
 
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 ;)

Bugsy 10-17-2010 23:39

Re: How can i read all data in a fvault file?
 
how big is your dest string? Show code

Enum 10-18-2010 11:12

Re: How can i read all data in a fvault file?
 
Quote:

Originally Posted by Bugsy (Post 1328141)
how big is your dest string? Show code

I tried with UsingForwards and works fine, thanks!

A last question :oops:

If i wanna print this:

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


how can i make this? Thanks.

fysiks 10-18-2010 12:56

Re: How can i read all data in a fvault file?
 
Code:

client_print( id, print_chat, "Name: %s - %d/%d/%d at %d:%d", name, num1, num2, num3, num4, num5)


All times are GMT -4. The time now is 10:25.

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