Raised This Month: $ Target: $400
 0% 

Nvault won't save or load


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-19-2012 , 18:57   Re: Nvault won't save or load
Reply With Quote #7

It would be better to provide your constants\vars\enums, since I didn't have these I created dummies.

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

enum MaxRaces
{
    
None,
    
a,
    
b,
    
c,
    
d
}

new 
PlayerLevel33 ][ MaxRaces ];
new 
PlayerXP33 ][ MaxRaces ];
new 
PlayerPoints33 ][ MaxRaces ];
new 
Nvault;

const 
MaxNumberLen 5;

public 
plugin_init() 
{
    
register_plugin"Test" "0.1" "bugsy" );
    
    
Nvault nvault_open"blah" );
    
    
register_clcmd"say test" "TestData" );
    
register_clcmd"say save" "SaveData" );
    
register_clcmd"say load" "LoadData" );
    
register_clcmd"say show" "ShowData" );
}

public 
plugin_end()
{
    
nvault_closeNvault );
}

public 
TestDataid )
{
    for ( new 
MaxRaces:MaxRaces:MaxRaces i++ )
    {
        
PlayerLevelid ][ ] = random_num1000 );
        
PlayerXPid ][ ] = random_num1001 2000 );
        
PlayerPointsid ][ ] = random_num2001 3000 );
    }
}

public 
ShowDataid )
{
    
client_printid print_chat "%d %d %d / %d %d %d / %d %d %d / %d %d %d" 
        
PlayerLevelid ][ ],
        
PlayerXPid ][ ],
        
PlayerPointsid ][ ],
        
        
PlayerLevelid ][ ],
        
PlayerXPid ][ ],
        
PlayerPointsid ][ ],
        
        
PlayerLevelid ][ ],
        
PlayerXPid ][ ],
        
PlayerPointsid ][ ],

        
PlayerLevelid ][ ],
        
PlayerXPid ][ ],
        
PlayerPointsid ][ ] );
}
        
public 
SaveDataid )
{
    new 
szKey32 ] , szData[ ( ( MaxNumberLen ) * _:MaxRaces ) + ] , iLen iPos;
    
    
iLen get_user_ipid szKeycharsmaxszKey ) );
    
copyszKeyiLen ] , charsmaxszKey ) - iLen "-xWar" );
    
    for ( new 
MaxRaces:RaceID MaxRaces:RaceID MaxRaces RaceID++)
    {
        
iPos += formatexszDataiPos ] , charsmaxszData ) - iPos "%05d %05d %05d "PlayerLevel[id][RaceID], PlayerXP[id][RaceID], PlayerPoints[id][RaceID])
        
server_printszData );
    }
    
    
nvault_setNvault szKey szData );
}

public 
LoadData(id)
{
    new 
szKey32 ] , szData[ ( ( MaxNumberLen ) * _:MaxRaces ) + ] , iLen;
    new 
LevelMaxNumberLen ] , XPMaxNumberLen ] , PointsMaxNumberLen ];
    
    
iLen get_user_ipid szKeycharsmaxszKey ) );
    
copyszKeyiLen ] , charsmaxszKey ) - iLen "-xWar" );
    
    
nvault_getNvault szKey szData charsmaxszData ) );

    for ( new 
MaxRaces:RaceID MaxRaces:RaceID MaxRaces RaceID++ )
    {
        
parseszData[ ( _:RaceID ) * ( * ( MaxNumberLen ) ) ] , Level charsmaxLevel ) , XP charsmaxXP ), Points charsmaxPoints ) ); 
        
        
PlayerLevel[id][RaceID] = str_to_numLevel );
        
PlayerXP[id][RaceID] = str_to_numXP );
        
PlayerPoints[id][RaceID] = str_to_numPoints );
    }

__________________

Last edited by Bugsy; 06-10-2012 at 11:25.
Bugsy is offline
 



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


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