Raised This Month: $32 Target: $400
 8% 

Doesn't load nvault data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 12-03-2015 , 11:16   Doesn't load nvault data
Reply With Quote #1

Need help, how to make load points with loop? Without loop they are loading fine.
PHP Code:
Load_DataiPlayer )
{
    new 
szKey64 ];
    new 
szData64 ];

    
formatexszKeycharsmaxszKey ), "%s"g_szAuthIDiPlayer ] );

    
//for( new i = 0; i < g_iTotal; i++ )
    //    formatex( szData, charsmax( szData ), "%d", g_iPoints[ iPlayer ] );

    
nvault_getg_iVaultszKeyszDatacharsmaxszData ) );

    new 
szPoints];

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


~Ice*shOt is offline
Send a message via Skype™ to ~Ice*shOt
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-03-2015 , 17:06   Re: Doesn't load nvault data
Reply With Quote #2

1. What is g_iTotal? Where do you set its value?
2. What does the log print out?
PartialCloning is offline
ironskillz1
AlliedModders Donor
Join Date: Jul 2012
Location: Sweden
Old 12-03-2015 , 17:13   Re: Doesn't load nvault data
Reply With Quote #3

Quote:
Originally Posted by ~Ice*shOt View Post
Need help, how to make load points with loop? Without loop they are loading fine.
PHP Code:
Load_DataiPlayer )
{
    new 
szKey64 ];
    new 
szData64 ];

    
formatexszKeycharsmaxszKey ), "%s"g_szAuthIDiPlayer ] );

    
//for( new i = 0; i < g_iTotal; i++ )
    //    formatex( szData, charsmax( szData ), "%d", g_iPoints[ iPlayer ] );

    
nvault_getg_iVaultszKeyszDatacharsmaxszData ) );

    new 
szPoints];

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


Why are you trying to load points with a loop.

Tell us instead what you are trying todo and we can help you easier
__________________
I have many private and unique plugins for Jailbreak and Hide'N'Seek. PM me for more info.

Pm me.

Check out my roulette site.
ironskillz1 is offline
Send a message via Skype™ to ironskillz1
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2015 , 18:49   Re: Doesn't load nvault data
Reply With Quote #4

You shouldn't post code without including all variables that are referenced. You should also include more information about what you are trying to do.

"how to make load points with loop? Without loop they are loading fine."

How many items are stored in each vault entry?
Is g_iPoints a 2-dimensional array and sized large enough?
What is the value of g_iTotal?

You should make sure g_iTotal is a constant variable and that its value is never larger than the size of the second dimension of g_iPoints or else you can run into index out of bounds errors.
__________________
Bugsy is offline
~Ice*shOt
Veteran Member
Join Date: Mar 2009
Location: Lithuania
Old 12-04-2015 , 06:15   Re: Doesn't load nvault data
Reply With Quote #5

Saving works fine, for example I set points g_iPoints[ iPlayer ][ 3 ] it printout

Quote:
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 200
L 12/03/2015 - 18:13:14: [test.amxx] 0
but when it's loading it printout

Quote:
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
L 12/03/2015 - 18:13:14: [test.amxx] 0
g_iTotal value is always 5.

PHP Code:
new g_iTotal;

new 
g_iPoints[33][5];

public 
native_registeriPluginiParams )
{
    new 
eDataData ];

    
get_string1eDataName ], charsmaxeDataName ] ) );

    
eDataCost ] = get_param);

    
ArrayPushArrayg_aDataeData );
    
g_iTotal++;

    return ( 
g_iTotal );
}

Save_DataiPlayer )
{
    new 
szKey64 ];
    new 
szData64 ];

    
formatexszKeycharsmaxszKey ), "%s"g_szAuthIDiPlayer ] );

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

        
log_amx"%d"g_iPointsiPlayer ][ ] );
    }

    
nvault_setg_iVaultszKeyszData );

P.S. no errors, nothing.

Last edited by ~Ice*shOt; 12-04-2015 at 06:17.
~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-04-2015 , 07:38   Re: Doesn't load nvault data
Reply With Quote #6

In your save, try "%d " instead of "%d". How else is parse supposed to know where numbers are separate? Your load function also needs to be fixed
__________________

Last edited by Bugsy; 12-04-2015 at 07:45.
Bugsy is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 12-04-2015 , 09:12   Re: Doesn't load nvault data
Reply With Quote #7

you overwrite szData in the for loop with every iteration.
when you use nvault_set only the last value is present in there.
jimaway is offline
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 #8

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 #9

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 #10

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
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 20:03.


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