Raised This Month: $ Target: $400
 0% 

[HELP] nVault code error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Heartbeat
Member
Join Date: Nov 2011
Location: Denmark
Old 01-02-2012 , 07:16   [HELP] nVault code error
Reply With Quote #1

I tried to make my own saving method but then now the server keeps crashing when this save method is enabled. So can you please help me?

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

new g_iVault
new g_iAuthID33 ][ 36 ]

public 
client_putinserver(iPlayer)
    
Load(iPlayer)

public 
client_disconnect(iPlayer)
    
Save(iPlayer)

public 
plugin_end()
    
nvault_close(g_iVault)

Load(iPlayer)
{
    static 
data256 ], timestamp
    
if( nvault_lookupg_iVaultg_iAuthIDiPlayer ], datasizeofdata ) - 1timestamp ) )
    {
        
ParseLoadDataiPlayerdata )
        return
    }
    else
    {
        
NewUseriPlayer )
    }
}

ParseLoadDataiPlayerdata256 ] )
{
    new 
num]
    
    for(new 
iAch 0iAch AchievesiAch++)
    {
        
strbreakdatanumsizeofnum ) - 1datasizeofdata ) - )
        
AchNameiPlayer ][ Achieves ] = clampstr_to_numnum ), 0AchRequirement[iAch] )
    }
}

public 
NewUseriPlayer )
{
    
    for(new 
iAch 0iAch AchievesiAch++)
    {
        
AchNameiPlayer ][ Achieves ] = 0
    
}

}

public 
SaveiPlayer )
{
    static 
data256 ]
    new 
len
    
    
for(new iAch 0iAch AchievesiAch++)
    {
        
len += formatexdatalen ], sizeofdata ) - len 1" %i"AchNameiPlayer ][ Achieves ] )
    }

    
nvault_setg_iVaultg_iAuthIDiPlayer ], data )


Last edited by Heartbeat; 01-02-2012 at 07:22.
Heartbeat is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-02-2012 , 21:26   Re: [HELP] nVault code error
Reply With Quote #2

There could be other crap wrong but something I noticed quickly is you have the wrong variable to access the array element; use iAch, not Achieves.
Code:
ParseLoadData( iPlayer, data[ 256 ] ) {     new num[ 6 ]         for(new iAch = 0; iAch < Achieves; iAch++)     {         strbreak( data, num, sizeof( num ) - 1, data, sizeof( data ) - 1 )         AchName[ iPlayer ][ Achieves ] = clamp( str_to_num( num ), 0, AchRequirement[iAch] )     } } public NewUser( iPlayer ) {         for(new iAch = 0; iAch < Achieves; iAch++)     {         AchName[ iPlayer ][ Achieves ] = 0     } } public Save( iPlayer ) {     static data[ 256 ]     new len         for(new iAch = 0; iAch < Achieves; iAch++)     {         len += formatex( data[ len ], sizeof( data ) - len - 1, " %i", AchName[ iPlayer ][ Achieves ] )     }     nvault_set( g_iVault, g_iAuthID[ iPlayer ], data ) }
__________________
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 11:00.


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