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

[SOLVED] nVault Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-23-2011 , 02:12   [SOLVED] nVault Problem
Reply With Quote #1

PHP Code:

enum _
:Achievements
{
    
Achievement_Name256 ],
    
Achievement_Progress33 ],
    
Achievement_Requirement,
    
Achievement_Reward,
    
Achievement_Type
}


public 
client_putinserverid )
{
    new 
aDataAchievements ];
    
    new 
iProgress33 ];
    
    for( new 
0g_iTotalAchievementsi++ )
    {
        
ArrayGetArrayg_aAchievementsiaData );
        
iProgress aDataAchievement_Progress ];
        
        
iProgressid ] = 0;
        
        
aDataAchievement_Progress ] = iProgress;
        
ArraySetArrayg_aAchievementsiaData );
    }
    
    
LoadDataid );
}

public 
SaveDataid )
{
    new 
szSteamID35 ];
    
get_user_authididszSteamIDcharsmaxszSteamID ) );
    
    new 
aDataAchievements ];
    
    new 
iProgress33 ], szProgress];
    
    new 
szKey512 ];
    
    for( new 
0g_iTotalAchievementsi++ )
    {
        
ArrayGetArrayg_aAchievementsiaData );
        
        
iProgress aDataAchievement_Progress ];
        
num_to_striProgressid ], szProgresscharsmaxszProgress ) );
        
        
formatexszKeycharsmaxszKey ), "%s-%s"aDataAchievement_Name ], szSteamID );
        
        
nvault_setg_hVaultszKeyszProgress );
        
        
server_print"NVAULT DEBUG SAVE - %s - %i"aDataAchievement_Name ], iProgressid ] );
    }
}  

public 
LoadDataid )
{
    new 
szSteamID35 ];
    
get_user_authididszSteamIDcharsmaxszSteamID ) );
    
    new 
aDataAchievements ];
    
    new 
iAchievementProgress33 ], iPlayerProgress;
    
    new 
szKey512 ];
    
    for( new 
0g_iTotalAchievementsi++ )
    {
        
ArrayGetArrayg_aAchievementsiaData );
        
        
formatexszKeycharsmaxszKey ), "%s-%s"aDataAchievement_Name ], szSteamID );
        
iPlayerProgress nvault_getg_hVaultszKey );

        
iAchievementProgress aDataAchievement_Progress ];
        
iAchievementProgressid ] = iPlayerProgress;
        
aDataAchievement_Progress ] = iAchievementProgress;
        
        
ArraySetArrayg_aAchievementsiaData );
        
        
server_print"NVAULT DEBUG - %s - %i"aDataAchievement_Name ], iPlayerProgress );
    }


For some reason, even if there is no vault data beforehand, the player always has all cells in Achievement_Progress for all achievements set to 16.

Any ideas?
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please

Last edited by nikhilgupta345; 07-27-2011 at 17:18.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-23-2011 , 02:35   Re: nVault Problem
Reply With Quote #2

Not sure, though you could reduce this:
PHP Code:
        iAchievementProgress aDataAchievement_Progress ]; 
        
iAchievementProgressid ] = iPlayerProgress
        
aDataAchievement_Progress ] = iAchievementProgress
to this:
PHP Code:
        aDataAchievement_Progress ][ id ] = iPlayerProgress
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-23-2011 , 02:46   Re: nVault Problem
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Not sure, though you could reduce this:
PHP Code:
        iAchievementProgress aDataAchievement_Progress ]; 
        
iAchievementProgressid ] = iPlayerProgress
        
aDataAchievement_Progress ] = iAchievementProgress
to this:
PHP Code:
        aDataAchievement_Progress ][ id ] = iPlayerProgress

Hmm just realized I've been doing that in the whole plugin. Thanks for the optimization

I have no idea why it's automatically starting at 16. I stop the server, delete the vault file, and then restart it, and when I first create an achievement, I logged it to be equal to 0, but then when I join the server, it gets set to 16.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 07-23-2011 , 03:58   Re: nVault Problem
Reply With Quote #4

16 is a weird number, considering you have no constant integers (as far as I can see) being assigned in the code shown. Perhaps the issue is coming from another bit.

What is the value of g_iTotalAchievements? Does the server you're testing it on have a maximum of 16 slots (get_maxplayers())?
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-23-2011 , 04:46   Re: nVault Problem
Reply With Quote #5

Yes the server has 16 slots.

The value of g_iTotalAchievements is 15.


But none of those numbers are related, because I just tested it again, and now the number is 84..
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-27-2011 , 17:18   Re: nVault Problem
Reply With Quote #6

Seemed to have fixed it by using nvault_lookup instead of nvault_get and checking if they key existed beforehand, and if it didn't, then I would set it to 0.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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:13.


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