 |
|
Veteran Member
Join Date: Aug 2014
Location: Your mom house -Portugal
|

12-22-2014
, 04:23
Re: Nvault problem
|
#4
|
Quote:
Originally Posted by Bugsy
- Use steam id, not name. This only needs to be read once per player connection.
- Use charsmax() instead of manually specifying max chars
- I would need to see your full code to determine your issue, there's a chance you were not loading\saving at an appropriate time.
Untested.
PHP Code:
#include <amxmodx>
#include <nvault>
const MAX_PLAYERS = 32;
new g_Vault, g_Points[ MAX_PLAYERS + 1 ], g_szAuthID[ MAX_PLAYERS + 1 ][ 35 ];
public plugin_init()
{
g_Vault = nvault_open( "hello" );
}
public plugin_end()
{
nvault_close( g_Vault );
}
public client_authorized( id )
{
get_user_authid( id , g_szAuthID[ id ] , charsmax( g_szAuthID[] ) );
LoadData( id );
}
public client_disconnect( id )
{
SaveData( id );
}
public SaveData(id)
{
new vaultkey[64] , vaultdata[328];
formatex( vaultkey , charsmax( vaultkey ) , "Yo_%s" , g_szAuthID[ id ] );
formatex( vaultdata , charsmax( vaultdata ) , "%i#" , g_Points[ id ] );
nvault_set( g_Vault , vaultkey , vaultdata )
}
public LoadData(id)
{
new vaultkey[64], vaultdata[328] , g_point[32];
format( vaultkey , charsmax( vaultkey ) , "Yo_%s" , g_szAuthID[ id ] );
//You are about to read data from vault into the vaultdata variable so there is
//no reason to format it since it will be overwritten anyway.
//Don't do this -> format( vaultdata , 327 , "%i#", g_Points[id]);
nvault_get( g_Vault , vaultkey , vaultdata , charsmax( vaultdata ) )
replace_all( vaultdata , charsmax( vaultdata ) , "#" , " " );
parse( vaultdata , g_point , charsmax( g_point ) );
g_Points[ id ] = str_to_num( g_point );
}
|
With that code, it is not saving, and it doesnt even create any file.
|
|
|
|