PDA

View Full Version : New to nVault


GXLZPGX
06-24-2010, 05:33
Instead of working with cash (in Bugsy's nVault Tutorial), I would like it to save points. Something for you to edit:
public plugin_cfg()
{
g_Vault = nvault_open( "zombiedefiance" );

if ( g_Vault == INVALID_HANDLE )
set_fail_state( "Error opening nVault" );

nvault_prune( g_Vault , 0 , get_systime() - ( 86400 * get_pcvar_num( g_pExpireDays ) ) );
}

public plugin_end()
{
nvault_close( g_Vault );
}

public client_authorized(id)
{
get_user_authid( id , g_szAuthID[id] , 34 );
}

public cmdSavePoints(id)
{
new szMoney[7]; //Data holder for the money amount
new szKey[40]; //Key used to save money "STEAM_0:0:1234MONEY"

formatex( szKey , 39 , "%sMONEY" , g_szAuthID[id] );
formatex( szMoney, 6 , "%d" , cs_get_user_money(id) );

nvault_set( g_Vault , szKey , szMoney );

client_print_color( id, Blue, "^4[ZD]^3 ** Your money was saved to vault **" );
}

public cmdGetPoints(id)
{
new szKey[40];
formatex( szKey , 39 , "%sMONEY" , g_szAuthID[id] );
new iMoney = nvault_get( g_Vault , szKey );

if ( iMoney )
{
cs_set_user_money( id , iMoney , 1 );
nvault_remove( g_Vault , szKey );

client_print_color( id, Blue, "^4[ZD] ^3** Your money was loaded from vault:^4 $%d **", iMoney );
}
else
{
client_print_color( id, Blue, "^4[ZD] ^3** You have no money entry in vault. **" );
}
}

Thank you very much in advance.

wrecked_
06-25-2010, 01:48
new iPoints[33]

new g_Vault

new g_szAuthID[33][35]

public plugin_cfg()
{
g_Vault = nvault_open( "zombiedefiance" );

if ( g_Vault == INVALID_HANDLE )
set_fail_state( "Error opening nVault" );
}

public plugin_end()
{
nvault_close( g_Vault );
}

public client_authorized(id)
{
get_user_authid( id , g_szAuthID[id] , 34 );
}

public cmdSavePoints(id)
{
new szPoints[7]; //Data holder for the money amount
new szKey[40]; //Key used to save money "STEAM_0:0:1234MONEY"

formatex( szKey , 39 , "%sPOINTS" , g_szAuthID[id] );
formatex( szMoney, 6 , "%d" , iPoints[id] );

nvault_set( g_Vault , szKey , szPoints );

client_print_color( id, Blue, "^4[ZD]^3 ** Your points were saved to vault **" );
}

public cmdGetPoints(id)
{
new szKey[40];
formatex( szKey , 39 , "%sPOINTS" , g_szAuthID[id] );
new iMoney = nvault_get( g_Vault , szKey );

if ( iMoney )
{
iPoints[id] = iMoney
nvault_remove( g_Vault , szKey );

client_print_color( id, Blue, "^4[ZD] ^3** Your points were loaded from vault:^4 $%d **", iMoney );
}
else
{
client_print_color( id, Blue, "^4[ZD] ^3** You have no point entries in vault. **" );
}
}