Raised This Month: $ Target: $400
 0% 

Doesn't load nvault data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-04-2015 , 10:39   Re: Doesn't load nvault data
Reply With Quote #1

PHP Code:
new iPos

iPos 
+= formatexszDataiPos ] , charsmaxszData ) - iPos "%d "g_iPointsiPlayer ][ ] ); 
You need to do something like this, with iPos defined outside of the loop. You also need to fix your load function
__________________

Last edited by Bugsy; 12-04-2015 at 10:42.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-04-2015 , 21:31   Re: Doesn't load nvault data
Reply With Quote #2

PHP Code:
Save_DataiPlayer )
{
    new 
szData64 ] , iPos;

    
//You do not need to use format for this. You only need to use format when you need to actually format the string.
    //Instead, just pass g_szAuthID[] directly to the nvault native.
    //formatex( szKey, charsmax( szKey ), "%s", g_szAuthID[ iPlayer ] );

    
for( new 0g_iTotali++ )
    {
        
//formatex( szData, charsmax( szData ), "%d", g_iPoints[ iPlayer ][ i ] );
        
iPos += formatexszDataiPos ], charsmaxszData ) - iPos "%d "g_iPointsiPlayer ][ ] );
        
log_amx"%d"g_iPointsiPlayer ][ ] );
    }

    
//nvault_set( g_iVault, szKey, szData );
    
nvault_setg_iVault g_szAuthIDiPlayer ] , szData );
}

Load_DataiPlayer )
{
    new 
szData64 ] , szPts1] , szPts2] , szPts3] , szPts4] , szPts5];

    
nvault_getg_iVaultg_szAuthIDiPlayer ] , szData charsmaxszData ) );

    
parseszData szPts1 charsmaxszPts1 ) , szPts2 charsmaxszPts2 ) , szPts3 charsmaxszPts3 ) , szPts4 charsmaxszPts4 ) , szPts5 charsmaxszPts5 )  );

    
g_iPointsiPlayer ][ ] = str_to_numszPts1 );
    
g_iPointsiPlayer ][ ] = str_to_numszPts2 );
    
g_iPointsiPlayer ][ ] = str_to_numszPts3 );
    
g_iPointsiPlayer ][ ] = str_to_numszPts4 );
    
g_iPointsiPlayer ][ ] = str_to_numszPts5 );

__________________
Bugsy is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 12-05-2015 , 06:59   Re: Doesn't load nvault data
Reply With Quote #3

Hey everyone, thanks a lot for your replies and help

I made some testing, with this:

PHP Code:
    case 1g_iPointsiPlayer ][ ] += 100;
    case 
2g_iPointsiPlayer ][ ] += 200;
    case 
3g_iPointsiPlayer ][ ] += 300;

Save_DataiPlayer )
{
    new 
szData64 ];

    for( new 
0g_iTotali++ )
    {
        
formatexszDatacharsmaxszData ), "%d"g_iPointsiPlayer ][ ] );

        
log_amx"[%i] %d"ig_iPointsiPlayer ][ ] );
    }

    
nvault_setg_iVaultg_szAuthIDiPlayer ], szData );
}

Load_DataiPlayer )
{
    new 
szData64 ];

    
nvault_getg_iVaultg_szAuthIDiPlayer ], szDatacharsmaxszData ) );

    new  
szPoints];

    
parseszDataszPointscharsmaxszPoints ) );

    for( new 
0g_iTotali++ )
    {
        
g_iPointsiPlayer ][ ] = str_to_numszPoints );
        
log_amx"[%i] %d"ig_iPointsiPlayer ][ ] );
    }

Save:
Quote:
L 12/05/2015 - 13:532: [test.amxx] [0] 100
L 12/05/2015 - 13:532: [test.amxx] [1] 0
L 12/05/2015 - 13:532: [test.amxx] [2] 200
L 12/05/2015 - 13:532: [test.amxx] [3] 0
L 12/05/2015 - 13:532: [test.amxx] [4] 300
Load:
Quote:
L 12/05/2015 - 13:537: [test.amxx] [0] 300
L 12/05/2015 - 13:537: [test.amxx] [1] 300
L 12/05/2015 - 13:537: [test.amxx] [2] 300
L 12/05/2015 - 13:537: [test.amxx] [3] 300
L 12/05/2015 - 13:537: [test.amxx] [4] 300
So I would be grateful if we done it in my way, can anyone fix load function? It loads only last element how we see.
~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-05-2015 , 12:10   Re: Doesn't load nvault data
Reply With Quote #4

If you insist, you can do it that way but it is less efficient. The good part about it is you can easily modify the number of points that are savable without modifying much code. This method requires you use a AMX-X 1.8.3 build.

I recommend defining your variables like this to avoid issues, and allowing for easily/safely modifying the number of points that can be stored.
PHP Code:
const PointSize 5;
new 
g_iPointsMAX_PLAYERS ][ PointSize ]; 
PHP Code:
Save_DataiPlayer )
{
    new 
szData64 ] , iPos;
    
    for( new 
0PointSizei++ )
    {
        
iPos += formatexszDataiPos ] , charsmaxszData ) - iPos "%d " g_iPointsiPlayer ][ ] );
    }

    
nvault_setg_iVault g_szAuthIDiPlayer ] , szData );
}

Load_DataiPlayer )
{
    new 
szData64 ] , szPoints] , iPos iPointIndex;

    
nvault_getg_iVault g_szAuthIDiPlayer ] , szData charsmaxszData ) );

    while ( 
iPointIndex PointSize 
    {
        
iPos argparseszData iPos szPointscharsmaxszPoints ) );
        
g_iPointsiPlayer ][ iPointIndex++ ] = str_to_numszPoints );
        
        if ( 
iPos == -)
            break;
    }

__________________

Last edited by Bugsy; 12-05-2015 at 12:13.
Bugsy 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 18:13.


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