AlliedModders

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

GXLZPGX 06-24-2010 05:33

New to nVault
 
Instead of working with cash (in Bugsy's nVault Tutorial), I would like it to save points. Something for you to edit:
PHP Code:

public plugin_cfg()
{
    
g_Vault nvault_open"zombiedefiance" );
    
    if ( 
g_Vault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );

    
nvault_pruneg_Vault get_systime() - ( 86400 get_pcvar_numg_pExpireDays ) ) );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorized(id)
{
    
get_user_authidid 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"

    
formatexszKey 39 "%sMONEY" g_szAuthID[id] );
    
formatexszMoney"%d" cs_get_user_money(id) );
    
    
nvault_setg_Vault szKey szMoney );

    
client_print_coloridBlue"^4[ZD]^3 ** Your money was saved to vault **" );
}

public 
cmdGetPoints(id)
{
    new 
szKey[40];
    
formatexszKey 39 "%sMONEY" g_szAuthID[id] );
    new 
iMoney nvault_getg_Vault szKey );

    if ( 
iMoney )
    {
        
cs_set_user_moneyid iMoney );
        
nvault_removeg_Vault szKey );

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


Thank you very much in advance.

wrecked_ 06-25-2010 01:48

Re: New to nVault
 
Code:
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. **" );     } }


All times are GMT -4. The time now is 14:42.

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