AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   nVault Problem (https://forums.alliedmods.net/showthread.php?t=197139)

quilhos 09-29-2012 10:45

nVault Problem
 
What is wrong with this nvault system? (My server dont give logs, but he dont start and I have sure that nvault have the problem).

PHP Code:

#include < amxmodx >
#include < amxmisc >
#include < nvault  >
#include < nvault_util >

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "..."

new gVault
new g_iAuthID[33][32]

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
        
gVault nvault_open "Pointmod" )
}

public 
plugin_end ( )
{
        
nvault_close gVault )
}
 
public 
client_authorized iPlayer )
{
        
get_user_authid iPlayerg_iAuthID iPlayer ], charsmaxg_iAuthID[] ) )
       
        
Load iPlayer )
}
 
public 
client_disconnect iPlayer )
{
        
Save iPlayer )
}

public 
Load iPlayer )
{
        static 
data 256 ], timestamp
        
new gAuthID[32];
        
get_user_authid(iPlayergAuthIDcharsmax(gAuthID));
        if ( 
nvault_lookup gVaultg_iAuthID iPlayer ], datasizeof data ) - 1timestamp ) )
                
ParseLoadData iPlayerdata )
        else
                
NewUser iPlayer )
}
 
public 
NewUser iPlayer )
{
        
cFirstTime iPlayer ] = 1
 
        iPoint 
iPlayer ] = pStart
       
        
for ( new iTer 0iTer TUpgradesiTer++ )
                
TLevel iPlayer ] [ iTer ] = 0
        
for ( new iCT 0iCT CTUpgradesiCT++ )
                
CTLevel iPlayer ] [ iCT ] = 0
}
 
ParseLoadData iPlayerdata 256 ] )
{
        static 
num ]
        
strbreak datanumsizeof num ) - 1datasizeof data ) - )
       
        
iPoint iPlayer ] = str_to_num num )
       
        for ( new 
iTer 0iTer TUpgradesiTer++ )
        {
                
strbreak datanumsizeof num ) - 1datasizeof data ) - )
                
TLevel iPlayer ] [ iTer ] = clamp str_to_num num ), 0TMaxLevel iTer ] )
        }
        for ( new 
iCT 0iCT CTUpgradesiCT++ )
        {
                
strbreak datanumsizeof num ) - 1datasizeof data ) - )
                
CTLevel iPlayer ] [ iCT ] = clamp str_to_num num ), 0CTMaxLevel iCT ] )
        }
}
 
public 
Save iPlayer )
{
        static 
data 256 ]
        new 
gAuthID[32];
        
get_user_authid(iPlayergAuthIDcharsmax(gAuthID));
        new 
len formatex datasizeof data ) - 1"%i"iPoint iPlayer ] )
       
        for ( new 
iTer 0iTer TUpgradesiTer++ )
                
len += formatex data len ], sizeof data ) - len 1" %i"TLevel iPlayer ] [ iTer ] )
        for ( new 
iCT 0iCT CTUpgradesiCT++ )
                
len += formatex data len ], sizeof data ) - len 1" %i"CTLevel iPlayer ] [ iCT ] )
       
        
nvault_set gVaultg_iAuthID iPlayer ], data )



Liverwiz 09-29-2012 11:24

Re: nVault Problem
 
I have a few notes. And because i'm writing this while i'm reading through the code I may not actually solve the problem, but i'm looking.
1. in load function, you do not need to call get_user_authid again. You never use use gAuthID anyway.
2. g_iAuthID is a string, not an int. name it g_szAuthID -just a suggestion
3. I thaknk ParseLoadData should look like this: ParseLoadData(iPlayer, data, iMaxLen) i'm sure you can figure out why.
4. you seem to be missing a lot of variable declarations. cFirstTime, iPoint, pStart, Tlevel, etc
5. you should use charsmax() instead of sizeof(szString) - 1 -that's just easier to read, though functionally equivalent.

Other than that...i don't see the issue. I'd suggest logging everything that happens with the vault. The data saved, the data retrieved. etc etc. This will give you more of an idea of what's going on. use log_to_file native if you're not familiar with it.

quilhos 09-29-2012 11:41

Re: nVault Problem
 
I can send to you the complete code for PM? It's a private plugin x:

Liverwiz 09-29-2012 12:16

Re: nVault Problem
 
i'm lazy ATM and about to go AFK.
if those are actually defined i'll take your word for it.
Do the logging i suggested and report anything you learn from that.

quilhos 09-29-2012 12:25

Re: nVault Problem
 
The logging is useless, because my server crash, not if the pointmod is new, but when is "old". In the first time that I install the plugin, all works fine, but now the server crash...

Liverwiz 09-29-2012 12:45

Re: nVault Problem
 
OH! That happens to me a lot.
Its quite an unfortunate problem, but with a simple solution.
Delete your .vault file from your /data/nvault on your ftp
This should fix it.
I don't know why it happens.

quilhos 09-29-2012 12:50

Re: nVault Problem
 
But my players will lose the XP that they fight for..

Liverwiz 09-30-2012 08:49

Re: nVault Problem
 
Quote:

Originally Posted by quilhos (Post 1808989)
But my players will lose the XP that they fight for..

Back it up. Then delete it. See if it is a fix. Then you might be able to enter the data manually.

quilhos 09-30-2012 10:08

Re: nVault Problem
 
I fix this without delete anything.

Code:

1º- Download nVault Reader
2º- Search for a white spot (usual in the first entrie)
3º- Delete the white line
4º- Put in addons/amxmodx/data/vault your nvault file


Liverwiz 09-30-2012 10:21

Re: nVault Problem
 
Quote:

Originally Posted by quilhos (Post 1809670)
I fix this without delete anything.

Code:

1º- Download nVault Reader
2º- Search for a white spot (usual in the first entrie)
3º- Delete the white line
4º- Put in addons/amxmodx/data/vault your nvault file


OH! That's an awesome note! Thanks for sharing. It'll save me aggravation in the future.


All times are GMT -4. The time now is 08:19.

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