#if defined _nve_included
#endinput
#endif
#define _nve_included
#include <amxmodx>
#include <nvault>
new gVault;
new gVaultName[] = "NvaultEasy";
const NVE_VERSION = 1.2;
/**
* Open the NvaultEasy.vault file
* @noreturn
*/
stock nve_open( )
{
gVault = nvault_open( gVaultName );
if( gVault == INVALID_HANDLE )
set_fail_state( " Problems with Nvault Easy include ... " );
}
/**
* Close the NvaultEasy.vault file.
* @noreturn
*/
stock nve_close( ) nvault_close( gVault );
/**
* @return: The vault id wich handle the vault file ( You may want for using normal nvault natives, maybe for the same file ).
*/
stock nve_vault_id( ) return gVault;
/**
* Save an integer to an index, you need to use a symbol to make it unique.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param Number The number to save ( the integer ) .
* @noreturn
*/
stock nve_set_int( id, szSymb[], Number )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
new szData[11];
num_to_str( Number, szData, charsmax( szData ) );
nvault_set( gVault, buffer, szData );
}
/**
* Get an integer from an index
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @return: The Number
*/
stock nve_get_int( id, szSymb[] )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
return nvault_get( gVault, buffer );
}
/**
* Update an integer from an index ( same as nve_get_int() you use this when your user is changing his name to retrieve the actual integer for his actual name. )
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @return: The Number
*/
stock nve_update_int( id, szSymb[] )
{
new buffer[64];
new szName[32];
get_user_info( id, "name", szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
return nvault_get( gVault, buffer );
}
/**
* Save an string to an index, you need to use a symbol to make it unique.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string to save ( "this is a string" )
* @noreturn
*/
stock nve_set_string( id, szSymb[], String[] )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
nvault_set( gVault, buffer, String );
}
/**
* Get an string from an index
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string variable to insert the saved string ( "this is a string" )
* @param lengh The lengh of the String variable ( Note: user charsmax() )
* @noreturn
*/
stock nve_get_string( id, szSymb[], String[] , lengh=64 )
{
new buffer[64];
new szName[32];
get_user_name( id, szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
nvault_get( gVault, buffer, String, lengh );
}
/**
* Update an string from an index ( Same as nve_get_string, you use this when your user is changing his name to retrieve the actual string for his actual name.
*
* @param id The index of the player.
* @param szSymb The symbol to use for making the save unique for this plugin.
* @param String The string variable to insert the saved string ( "this is a string" )
* @param lengh The lengh of the String variable ( Note: user charsmax() )
* @noreturn
*/
stock nve_update_string( id, szSymb[], String[] , lengh=64 )
{
new buffer[64];
new szName[32];
get_user_info( id, "name", szName, charsmax( szName ) );
formatex( buffer, charsmax( buffer ), "%s%s", szSymb, szName );
nvault_get( gVault, buffer, String, lengh );
}
/**
* Reset a vault, so it deletes all the entries ( #RO: Sterge toate salvarile, goloseste vault-ul. )
* @noreturn
*/
stock nve_reset( )
{
nvault_prune( gVault, 0, get_systime( ) );
}